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 Jan 31, 2023
1 parent 568fc02 commit 0fc2953
Show file tree
Hide file tree
Showing 13 changed files with 867 additions and 562 deletions.
4 changes: 4 additions & 0 deletions cspell.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 0fc2953

Please sign in to comment.