feat: add supplemental SDL config#4803
Open
yaacovCR wants to merge 4 commits into
Open
Conversation
|
@yaacovCR is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel. A member of the Team first needs to authorize it. |
3b4b876 to
2dc804b
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
b59fc35 to
18c849d
Compare
4 tasks
Add `supplementalConfig` to `buildSchema`, `buildASTSchema`, and `extendSchema` so SDL-defined schema elements can receive constructor-only configuration that SDL cannot express. The option is validated by default and can be bypassed with `assumeValidSupplementalConfig` for config that has already been checked. The schema-level config is keyed by schema element kind and GraphQL name: - `scalarTypes`: `serialize`, `parseValue`, `parseLiteral`, `coerceOutputValue`, `coerceInputValue`, `coerceInputLiteral`, `valueToLiteral`, and `extensions`. - `objectTypes`: `fields`, `isTypeOf`, and `extensions`. - `interfaceTypes`: `fields`, `resolveType`, and `extensions`. - `unionTypes`: `resolveType` and `extensions`. - `enumTypes`: `values` and `extensions`; enum values can define an internal `value` and `extensions`. - `inputObjectTypes`: `fields` and `extensions`. - `directives`: `args` and `extensions`. - `extensions`: schema extensions. Field supplements can be a resolver function or an object with `resolve`, `subscribe`, `args`, and `extensions`. Argument, input field, directive argument, enum value, and type supplements apply only to schema elements declared or extended by the SDL document, and unmatched supplemental config is rejected by default. This lets SDL own the type-system shape while JavaScript supplies runtime behavior and host-language metadata: field resolvers, subscription functions, abstract type resolution, object type predicates, custom scalar coercion and literal conversion, enum runtime values, and extensions. Related issues: graphql#497, graphql#499, graphql#516, graphql#525, graphql#604, graphql#622, graphql#1379, graphql#1858. Related prior PRs: graphql#469, graphql#947, graphql#1384, graphql#1987.
18c849d to
1bb3f67
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add
supplementalConfigtobuildSchema,buildASTSchema, andextendSchemaso SDL-defined schema elements can receive constructor-only configuration that SDL cannot express. The option is validated by default and can be bypassed withassumeValidSupplementalConfigfor config that has already been checked.The schema-level config is keyed by schema element kind and GraphQL name:
scalarTypes:serialize,parseValue,parseLiteral,coerceOutputValue,coerceInputValue,coerceInputLiteral,valueToLiteral, andextensions.objectTypes:fields,isTypeOf, andextensions.interfaceTypes:fields,resolveType, andextensions.unionTypes:resolveTypeandextensions.enumTypes:valuesandextensions; enum values can define an internalvalueandextensions.inputObjectTypes:fieldsandextensions.directives:argsandextensions.extensions: schema extensions.Field supplements can be a resolver function or an object with
resolve,subscribe,args, andextensions. Argument, input field, directive argument, enum value, and type supplements apply only to schema elements declared or extended by the SDL document, and unmatched supplemental config is rejected by default.This lets SDL own the type-system shape while JavaScript supplies runtime behavior and host-language metadata: field resolvers, subscription functions, abstract type resolution, object type predicates, custom scalar coercion and literal conversion, enum runtime values, and extensions.
Related issues: #497, #499, #516, #525, #604, #622, #1379, #1858.
Related prior PRs: #469, #947, #1384, #1987.