Skip to content

Commit 2331ba5

Browse files
leebyronyaacovCR
authored andcommitted
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 e833a5a commit 2331ba5

13 files changed

+867
-562
lines changed

cspell.yml

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ ignoreRegExpList:
2727

2828
words:
2929
- graphiql
30+
- sublinks
31+
- instanceof
32+
- uncoerce
33+
- uncoerced
3034

3135
# Different names used inside tests
3236
- Skywalker

src/execution/__tests__/variables-test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ const TestType = new GraphQLObjectType({
104104
}),
105105
fieldWithNestedInputObject: fieldWithInputArg({
106106
type: TestNestedInputObject,
107-
defaultValue: 'Hello World',
108107
}),
109108
list: fieldWithInputArg({ type: new GraphQLList(GraphQLString) }),
110109
nnList: fieldWithInputArg({

src/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,6 @@ export {
440440
typeFromAST,
441441
// Create a JavaScript value from a GraphQL language AST without a Type.
442442
valueFromASTUntyped,
443-
// Create a GraphQL language AST from a JavaScript value.
444-
astFromValue,
445443
// A helper to use within recursive-descent visitors which need to be aware of the GraphQL type system.
446444
TypeInfo,
447445
visitWithTypeInfo,

src/type/__tests__/enumType-test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ const QueryType = new GraphQLObjectType({
6363
args: {
6464
fromEnum: {
6565
type: ComplexEnum,
66-
// Note: defaultValue is provided an *internal* representation for
67-
// Enums, rather than the string name.
68-
defaultValue: Complex1,
66+
defaultValue: 'ONE',
6967
},
7068
provideGoodValue: { type: GraphQLBoolean },
7169
provideBadValue: { type: GraphQLBoolean },

0 commit comments

Comments
 (0)