-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Avoid duplicate cacheControl
directives via isDirectiveDefined
(redo)
#2762
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Anything blocking this from being merged? I seem to encounter similar problems. Error: There can be only one type named "CacheControlScope".
Enum value "CacheControlScope.PUBLIC" can only be defined once.
Enum value "CacheControlScope.PRIVATE" can only be defined once.
There can be only one type named "Upload".
at assertValidSDL (D:\dev\proj\fastlearn-server\server\node_modules\graphql\validation\validate.js:89:11)
at Object.buildASTSchema (D:\dev\proj\fastlearn-server\server\node_modules\graphql\utilities\buildASTSchema.js:78:34)
at Object.buildSchemaFromTypeDefinitions (D:\dev\proj\fastlearn-server\server\node_modules\graphql-tools\src\generate\buildSchemaFromTypeDefinitions.ts:43:32)
at Object.makeExecutableSchema (D:\dev\proj\fastlearn-server\server\node_modules\graphql-tools\src\makeExecutableSchema.ts:52:16)
at new ApolloServerBase (D:\dev\proj\fastlearn-server\server\node_modules\apollo-server-core\src\ApolloServer.ts:302:21)
at new ApolloServer (D:\dev\proj\fastlearn-server\server\node_modules\apollo-server-express\src\ApolloServer.ts:84:5)
at Object.<anonymous> (D:\dev\proj\fastlearn-server\server\src\app.ts:54:16)
at Module._compile (internal/modules/cjs/loader.js:734:30)
at Module._compile (D:\dev\proj\fastlearn-server\server\node_modules\source-map-support\source-map-support.js:521:25)
at Module.m._compile (C:\Users\e\AppData\Local\Temp\ts-node-dev-hook-9660947657511609.js:56:25)
[ERROR] 14:43:08 Error: There can be only one type named "CacheControlScope".
Enum value "CacheControlScope.PUBLIC" can only be defined once.
Enum value "CacheControlScope.PRIVATE" can only be defined once.
There can be only one type named "Upload".
Is this related to this commit? |
cheapsteak
force-pushed
the
chang/avoid-duplicate-directives-redo
branch
from
June 24, 2019 13:24
0949bd4
to
ed38ef7
Compare
@gotexis it should help (as long as there otherwise only exists one declaration of the |
abernix
added a commit
to mrsunboss/apollo-server
that referenced
this pull request
Jun 26, 2019
…eality. While no TypeScript user would have ever been able to use it as such, Apollo Server has for a long time (as a side-effect of its past reliance on `graphql-tools`) accepted string types (and arrays of string types) for `typeDefs`. This hasn't been reflected in the TypeScript types, and has thus made it possible to sandbag non-TypeScript users (which let's remind ourselves, is still the majority) who were strings, when new code — like that in apollographql#2762 — didn't defend against what TypeScript indicated would be fine. Even if we don't necessarily support string types as a common pattern anymore, they still work, and we need to make sure we're coding for what we expect to work until the time comes to make a breaking change.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a redo of #2428 , which inadvertently broke passing in strings as typedefs and was reverted in 2.6.1
This PR adds a utility function
isDirectiveDefined
and uses it to guard against duplicate directives when the user's schema already contains a directive (in this case,cacheControl
). It also handles when typeDefs is a string (with corresponding tests added)