Skip to content

Commit

Permalink
RFC: Default value validation & coercion
Browse files Browse the repository at this point in the history
Implements graphql/graphql-spec#793

* Adds validation of default values during schema validation.
* Adds coercion of default values anywhere a default value is used at runtime

Potentially breaking:
* Remove `astFromValue`
* Changes type of `defaultValue` provided during type configuration from an "internal" to an "external" value.
  • Loading branch information
leebyron authored and yaacovCR committed Feb 6, 2023
1 parent 1d1b883 commit ad69cea
Show file tree
Hide file tree
Showing 13 changed files with 867 additions and 562 deletions.
4 changes: 4 additions & 0 deletions cspell.yml
Expand Up @@ -27,6 +27,10 @@ ignoreRegExpList:

words:
- graphiql
- sublinks
- instanceof
- uncoerce
- uncoerced

# Different names used inside tests
- Skywalker
Expand Down
1 change: 0 additions & 1 deletion src/execution/__tests__/variables-test.ts
Expand Up @@ -126,7 +126,6 @@ const TestType = new GraphQLObjectType({
}),
fieldWithNestedInputObject: fieldWithInputArg({
type: TestNestedInputObject,
defaultValue: 'Hello World',
}),
list: fieldWithInputArg({ type: new GraphQLList(GraphQLString) }),
nnList: fieldWithInputArg({
Expand Down
2 changes: 0 additions & 2 deletions src/index.ts
Expand Up @@ -440,8 +440,6 @@ export {
typeFromAST,
// Create a JavaScript value from a GraphQL language AST without a Type.
valueFromASTUntyped,
// Create a GraphQL language AST from a JavaScript value.
astFromValue,
// A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system.
TypeInfo,
visitWithTypeInfo,
Expand Down
4 changes: 1 addition & 3 deletions src/type/__tests__/enumType-test.ts
Expand Up @@ -63,9 +63,7 @@ const QueryType = new GraphQLObjectType({
args: {
fromEnum: {
type: ComplexEnum,
// Note: defaultValue is provided an *internal* representation for
// Enums, rather than the string name.
defaultValue: Complex1,
defaultValue: 'ONE',
},
provideGoodValue: { type: GraphQLBoolean },
provideBadValue: { type: GraphQLBoolean },
Expand Down

0 comments on commit ad69cea

Please sign in to comment.