Skip to content

Commit 0d975a4

Browse files
committed
RFC: Default value validation & coercion
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.
1 parent d1fbfb3 commit 0d975a4

13 files changed

Lines changed: 734 additions & 557 deletions

File tree

cspell.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ words:
2424
- graphiql
2525
- sublinks
2626
- instanceof
27+
- uncoerce
28+
- uncoerced
2729

2830
# Different names used inside tests
2931
- Skywalker

src/execution/__tests__/variables-test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ const TestType = new GraphQLObjectType({
103103
}),
104104
fieldWithNestedInputObject: fieldWithInputArg({
105105
type: TestNestedInputObject,
106-
defaultValue: 'Hello World',
107106
}),
108107
list: fieldWithInputArg({ type: new GraphQLList(GraphQLString) }),
109108
nnList: fieldWithInputArg({

src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,6 @@ export {
411411
typeFromAST,
412412
/** Create a JavaScript value from a GraphQL language AST without a Type. */
413413
valueFromASTUntyped,
414-
/** Create a GraphQL language AST from a JavaScript value. */
415-
astFromValue,
416414
/** A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system. */
417415
TypeInfo,
418416
visitWithTypeInfo,

src/type/__tests__/enumType-test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ const QueryType = new GraphQLObjectType({
6060
args: {
6161
fromEnum: {
6262
type: ComplexEnum,
63-
// Note: defaultValue is provided an *internal* representation for
64-
// Enums, rather than the string name.
65-
defaultValue: Complex1,
63+
defaultValue: 'ONE',
6664
},
6765
provideGoodValue: { type: GraphQLBoolean },
6866
provideBadValue: { type: GraphQLBoolean },

0 commit comments

Comments
 (0)