Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema type renaming not working with @include directive #3456

Closed
BobaFetters opened this issue Oct 4, 2024 · 2 comments
Closed

Schema type renaming not working with @include directive #3456

BobaFetters opened this issue Oct 4, 2024 · 2 comments
Assignees
Labels
bug Generally incorrect behavior

Comments

@BobaFetters
Copy link
Member

Issue reported in this thread https://graphchampions.slack.com/archives/C02L9FDUZKM/p1727826399718149 it appears that types that have been renamed through the config option aren't using their new name for an @include directive usage.

From the original report:

I specified the following in my config:

"schemaCustomization" : {
		    "customTypeNames" : {
		      "CustomV2" : "CustomNew"
		    }
		}

it works great for fields, and generates CustomNew interface:
static let CustomNew = ApolloAPI.Interface(name: "CustomV2")
However, in one of my queries, it skips to use the alias I want, when it’s wrapped in include directive:

static var __selections: [ApolloAPI.Selection] { [
      .field("__typename", String.self),
      .field("field1", Field1.self),
      .field("field2", GraphQL.Long.self),
      .include(if: "useCustomV2", .field("customV2", CustomV2.self)),
     ] }

I’d expect:

static var __selections: [ApolloAPI.Selection] { [
      .field("__typename", String.self),
      .field("field1", Field1.self),
      .field("field2", GraphQL.Long.self),
      .include(if: "useCustomV2", .field("customV2", CustomNew.self)),
     ] }
@BobaFetters BobaFetters added the bug Generally incorrect behavior label Oct 4, 2024
@BobaFetters BobaFetters self-assigned this Oct 4, 2024
@BobaFetters
Copy link
Member Author

The field in question is a Selection Set type and not a Schema type which is what the custom renaming is used for, this field would need to be renamed using a field alias in order to change its name. I have created an issue to add docs to help better explain this distinction here.

Copy link
Contributor

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Generally incorrect behavior
Projects
None yet
Development

No branches or pull requests

1 participant