buildSchema should be able to create fully featured schema#1987
buildSchema should be able to create fully featured schema#1987langpavel wants to merge 5 commits into
buildSchema should be able to create fully featured schema#1987Conversation
97b4b9b to
1b0f68a
Compare
|
|
||
| export type TypeFieldResolverMap = ObjMap< | ||
| | ObjMap<GraphQLFieldResolver<mixed, mixed, mixed>> /* type and interface */ | ||
| | ObjMap<any> /* enum */, |
There was a problem hiding this comment.
I don't like this much because any for enum will eat resolvers for object types.
Should I wrap enum values to object with key one key values? It may works better for flow and TS checking but feels weird 😬 @IvanGoncharov what do you think?
|
@langpavel Thanks, for PR 👍 Since this is a very complex feature and we would need the ability to iterate on it without doing breaking changes I want to postpone this particular feature after Meanwhile, I need to think about the general API design and how to handle a thing like this: scalar CustomScalarWithValidationRule
directive @SomeDirective(arg: CustomScalarWithValidationRule) on FIELD_DEFINITION
type Query {
foo: String @SomeDirective(arg: "<Invalid value for custom scalar>")
bar(arg: CustomScalarWithValidationRule = "<Invalid value for custom scalar>")
}We need ability to provide |
I definitely agree that this may be complex feature, but if you look into this PR, it's actually really easy to follow whats happens.
Ok, this ones:
This is already partially covered here: 396098e const scalarConfig = options.resolvers['CustomScalarWithValidationRule'];
const { serialize, parseValue, parseLiteral } = scalarConfig;Because Please, consider this merging soon, as this is only thing which allow me to drop |
396098e to
a1b8520
Compare
|
Related: ardatan/graphql-tools#1456 changes graphql-tools to no longer modify original schema in place and instead return a new rewired schema. |
@cvbedc Unknown command 😕 Supported commandsPlease post this commands in separate comments and only one per comment:
|
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.
|
Thank you so much for this PR pointing the way. Almost 7 years later, #4803 now implements this on top of 17.x.x ... |
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.
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.
buildSchema,buildASTSchemaandextendSchema:DONE: 🎉
enumvalue lookup (exactly like previous) 1b0f68aTO DO, need help:
isTypeOfon ObjectType (should I followgraphql-toolswith__isTypeOf?)resolveTypeon UnionType (same question as above)Related: #1384 #1858
/cc @IvanGoncharov, @leebyron