-
Notifications
You must be signed in to change notification settings - Fork 749
Using \r\n In GQL String Will Cause Invalid Swift Generation Using ApolloCLI #3553
Copy link
Copy link
Open
Labels
bugGenerally incorrect behaviorGenerally incorrect behaviorcodegenIssues related to or arising from code generationIssues related to or arising from code generationgood first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.low-priority
Milestone
Description
Summary
With the following GQL schema:
schema {
query: Query
}
type Query {
test(test: String): TestType
}
type TestType {
"Test\r\nTest\r\nTest\r\nTest"
test: String
}
And the following operation:
query Query {
test(test: "Hello") {
test
}
}
Running the ./apollo-cli-generate will cause this Swift code to be generated:
extension MySchema {
class Query: GraphQLQuery {
static let operationName: String = "Query"
static let operationDocument: ApolloAPI.OperationDocument = .init(
definition: .init(
#"query Query { test(test: "Hello") { __typename test } }"#
))
public init() {}
struct Data: MySchema.SelectionSet {
let __data: DataDict
init(_dataDict: DataDict) { __data = _dataDict }
static var __parentType: any ApolloAPI.ParentType { MySchema.Objects.Query }
static var __selections: [ApolloAPI.Selection] { [
.field("test", Test?.self, arguments: ["test": "Hello"]),
] }
var test: Test? { __data["test"] }
/// Test
///
/// Parent Type: `TestType`
struct Test: MySchema.SelectionSet {
let __data: DataDict
init(_dataDict: DataDict) { __data = _dataDict }
static var __parentType: any ApolloAPI.ParentType { MySchema.Objects.TestType }
static var __selections: [ApolloAPI.Selection] { [
.field("__typename", String.self),
.field("test", String?.self),
] }
/// Test
Test
Test
Test
var test: String? { __data["test"] }
}
}
}
}
As you can see, anything past the first \r\n is not commented, resulting in invalid syntax.
I've recreated this problem in this repo, which you can clone and run to reproduce yourself.
Version
1.21.0
Steps to reproduce the behavior
See above.
Logs
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugGenerally incorrect behaviorGenerally incorrect behaviorcodegenIssues related to or arising from code generationIssues related to or arising from code generationgood first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.low-priority