Skip to content

Multiple deprecation warning directives not compiling #3559

@guilherme-anchorage

Description

@guilherme-anchorage

Summary

We have encountered an issue with the code generation process that results in non-compilable code. When we have a field with multiple deprecation warnings, we have the same amount of #warning directives separated with a ,\n which does not compile with the following error - Extra tokens following #warning directive.

Version

1.21.0

Steps to reproduce the behavior

To achieve this we had a query with multiple arguments, where 2 or more are deprecated.

Example:
This GraphQL schema definition

someQuery(
  argumentA: String @deprecated(reason: "Some reason")
  argumentB: String @deprecated(reason: "Some other reason")
): Object!

with the following GraphQL contract

query QueryA{ 
  someQuery(
    argumentA: "",
    argumentB: ""
  )
}

results in the following Swift code generation

public class QueryA: GraphQLQuery {
(...)
    #warning("Argument 'argumentA' of field 'someQuery' is deprecated. Reason: 'Some reason'"),  // Compilation error here
    #warning("Argument 'argumentB' of field 'someQuery' is deprecated. Reason: 'Some other reason'")
    public static var __selections: [ApolloAPI.Selection] { [
      .field("someQuery", Object.self, arguments: [
        "argumentA": "",
        "argumentB": ""
      ]),
    ] }
}

Logs

Anything else?

No response

Metadata

Metadata

Assignees

Labels

bugGenerally incorrect behaviorcodegenIssues related to or arising from code generation

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions