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

Handle duplicate enums across services #2829

Merged
merged 3 commits into from
Jun 14, 2019
Merged

Conversation

JakeDawkins
Copy link
Contributor

@JakeDawkins JakeDawkins commented Jun 11, 2019

  1. Removes existing validations for duplicate type names for Scalars and Enums (we expect duplicate definitions)
  2. Add new SDL validation rules for matching enums and scalars to allow for duplicates across services, but not within a service.
  3. Add pre-composition validation for duplicate enum values within a single service

Resolves #2767

@JakeDawkins JakeDawkins force-pushed the jake/fed-duplicate-enums branch 2 times, most recently from 006fde4 to 8ebd49d Compare June 14, 2019 15:50
@JakeDawkins JakeDawkins changed the title WIP Handle duplicate enums across services Handle duplicate enums across services Jun 14, 2019
const errors = validateSDL(definitionsDocument, schema, [matchingEnums]);
expect(errors).toMatchInlineSnapshot(`
Array [
[GraphQLError: [serviceA] ProductType -> ProductType is an enum in [serviceA, serviceC], but not in [serviceB]],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error could be clearer (the functionality is great)! Can we tell what kind of type it is in serviceB in this case? I.e. ProductType is an enum in [serviceA, serviceC], but is an object type in [serviceB]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. What if there were multiple services with ProductType and one was an object type, and the other was a Scalar?

Copy link
Contributor

@jbaxleyiii jbaxleyiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JakeDawkins this is so great! A few questions / nits and one request from me!

Can you add a test for internal representations (https://www.apollographql.com/docs/apollo-server/features/scalars-enums/#internal-values) and make sure that those don't have to be the same across services?

@jbaxleyiii jbaxleyiii merged commit b635f17 into master Jun 14, 2019
@jbaxleyiii jbaxleyiii deleted the jake/fed-duplicate-enums branch June 14, 2019 18:21
abernix pushed a commit to apollographql/federation that referenced this pull request Sep 4, 2020
…l/jake/fed-duplicate-enums

Handle duplicate enums across services
Apollo-Orig-Commit-AS: apollographql/apollo-server@b635f17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apollo Federation - Duplicate scalar in multiple services
2 participants