Skip to content

Commit f2d03c4

Browse files
committed
introduce GraphQLField, GraphQLInputField, GraphQLArgument, and GraphQLEnumValue
1 parent cca3f98 commit f2d03c4

22 files changed

+735
-552
lines changed

src/execution/__tests__/nonnull-test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ describe('Execute: handles non-nullable types', () => {
683683
errors: [
684684
{
685685
message:
686-
'Argument "cannotBeNull" of required type "String!" was not provided.',
686+
'Argument "Query.withNonNullArg(cannotBeNull:)" of required type "String!" was not provided.',
687687
locations: [{ line: 3, column: 13 }],
688688
path: ['withNonNullArg'],
689689
},
@@ -710,7 +710,7 @@ describe('Execute: handles non-nullable types', () => {
710710
errors: [
711711
{
712712
message:
713-
'Argument "cannotBeNull" has invalid value: Expected value of non-null type "String!" not to be null.',
713+
'Argument "Query.withNonNullArg(cannotBeNull:)" has invalid value: Expected value of non-null type "String!" not to be null.',
714714
locations: [{ line: 3, column: 42 }],
715715
path: ['withNonNullArg'],
716716
},
@@ -740,7 +740,7 @@ describe('Execute: handles non-nullable types', () => {
740740
errors: [
741741
{
742742
message:
743-
'Argument "cannotBeNull" has invalid value: Expected variable "$testVar" provided to type "String!" to provide a runtime value.',
743+
'Argument "Query.withNonNullArg(cannotBeNull:)" has invalid value: Expected variable "$testVar" provided to type "String!" to provide a runtime value.',
744744
locations: [{ line: 3, column: 42 }],
745745
path: ['withNonNullArg'],
746746
},
@@ -768,7 +768,7 @@ describe('Execute: handles non-nullable types', () => {
768768
errors: [
769769
{
770770
message:
771-
'Argument "cannotBeNull" has invalid value: Expected variable "$testVar" provided to non-null type "String!" not to be null.',
771+
'Argument "Query.withNonNullArg(cannotBeNull:)" has invalid value: Expected variable "$testVar" provided to non-null type "String!" not to be null.',
772772
locations: [{ line: 3, column: 43 }],
773773
path: ['withNonNullArg'],
774774
},

src/execution/__tests__/oneof-test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('Execute: Handles OneOf Input Objects', () => {
8888
message:
8989
// This type of error would be caught at validation-time
9090
// hence the vague error message here.
91-
'Argument "input" has invalid value: Expected variable "$input" provided to type "TestInputObject!" to provide a runtime value.',
91+
'Argument "Query.test(input:)" has invalid value: Expected variable "$input" provided to type "TestInputObject!" to provide a runtime value.',
9292
path: ['test'],
9393
},
9494
],
@@ -229,7 +229,7 @@ describe('Execute: Handles OneOf Input Objects', () => {
229229
// A nullable variable in a oneOf field position would be caught at validation-time
230230
// hence the vague error message here.
231231
message:
232-
'Argument "input" has invalid value: Expected variable "$a" provided to field "a" for OneOf Input Object type "TestInputObject" not to be null.',
232+
'Argument "Query.test(input:)" has invalid value: Expected variable "$a" provided to field "a" for OneOf Input Object type "TestInputObject" not to be null.',
233233
locations: [{ line: 3, column: 23 }],
234234
path: ['test'],
235235
},
@@ -257,7 +257,7 @@ describe('Execute: Handles OneOf Input Objects', () => {
257257
// A nullable variable in a oneOf field position would be caught at validation-time
258258
// hence the vague error message here.
259259
message:
260-
'Argument "input" has invalid value: Expected variable "$a" provided to field "a" for OneOf Input Object type "TestInputObject" to provide a runtime value.',
260+
'Argument "Query.test(input:)" has invalid value: Expected variable "$a" provided to field "a" for OneOf Input Object type "TestInputObject" to provide a runtime value.',
261261
locations: [{ line: 3, column: 23 }],
262262
path: ['test'],
263263
},
@@ -288,7 +288,7 @@ describe('Execute: Handles OneOf Input Objects', () => {
288288
// A nullable variable in a oneOf field position would be caught at validation-time
289289
// hence the vague error message here.
290290
message:
291-
'Argument "input" has invalid value: Expected variable "$a" provided to field "a" for OneOf Input Object type "TestInputObject" not to be null.',
291+
'Argument "Query.test(input:)" has invalid value: Expected variable "$a" provided to field "a" for OneOf Input Object type "TestInputObject" not to be null.',
292292
locations: [{ line: 6, column: 23 }],
293293
path: ['test'],
294294
},
@@ -319,7 +319,7 @@ describe('Execute: Handles OneOf Input Objects', () => {
319319
// A nullable variable in a oneOf field position would be caught at validation-time
320320
// hence the vague error message here.
321321
message:
322-
'Argument "input" has invalid value: Expected variable "$a" provided to field "a" for OneOf Input Object type "TestInputObject" to provide a runtime value.',
322+
'Argument "Query.test(input:)" has invalid value: Expected variable "$a" provided to field "a" for OneOf Input Object type "TestInputObject" to provide a runtime value.',
323323
locations: [{ line: 6, column: 23 }],
324324
path: ['test'],
325325
},

src/execution/__tests__/variables-test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ describe('Execute: Handles inputs', () => {
284284
errors: [
285285
{
286286
message:
287-
'Argument "input" has invalid value: Expected value of type "TestInputObject" to be an object, found: ["foo", "bar", "baz"].',
287+
'Argument "TestType.fieldWithObjectInput(input:)" has invalid value: Expected value of type "TestInputObject" to be an object, found: ["foo", "bar", "baz"].',
288288
path: ['fieldWithObjectInput'],
289289
locations: [{ line: 3, column: 41 }],
290290
},
@@ -320,7 +320,7 @@ describe('Execute: Handles inputs', () => {
320320
errors: [
321321
{
322322
message:
323-
'Argument "input" has invalid value at .e: FaultyScalarErrorMessage',
323+
'Argument "TestType.fieldWithObjectInput(input:)" has invalid value at .e: FaultyScalarErrorMessage',
324324
path: ['fieldWithObjectInput'],
325325
locations: [{ line: 3, column: 13 }],
326326
extensions: { code: 'FaultyScalarErrorExtensionCode' },
@@ -477,7 +477,7 @@ describe('Execute: Handles inputs', () => {
477477
errors: [
478478
{
479479
message:
480-
'Variable "$input" has invalid value at .e: Argument "input" has invalid value at .e: FaultyScalarErrorMessage',
480+
'Variable "$input" has invalid value at .e: Argument "TestType.fieldWithObjectInput(input:)" has invalid value at .e: FaultyScalarErrorMessage',
481481
locations: [{ line: 2, column: 16 }],
482482
extensions: { code: 'FaultyScalarErrorExtensionCode' },
483483
},
@@ -802,7 +802,7 @@ describe('Execute: Handles inputs', () => {
802802
errors: [
803803
{
804804
message:
805-
'Argument "input" of required type "String!" was not provided.',
805+
'Argument "TestType.fieldWithNonNullableStringInput(input:)" of required type "String!" was not provided.',
806806
locations: [{ line: 1, column: 3 }],
807807
path: ['fieldWithNonNullableStringInput'],
808808
},
@@ -850,7 +850,7 @@ describe('Execute: Handles inputs', () => {
850850
errors: [
851851
{
852852
message:
853-
'Argument "input" has invalid value: Expected variable "$foo" provided to type "String!" to provide a runtime value.',
853+
'Argument "TestType.fieldWithNonNullableStringInput(input:)" has invalid value: Expected variable "$foo" provided to type "String!" to provide a runtime value.',
854854
locations: [{ line: 3, column: 50 }],
855855
path: ['fieldWithNonNullableStringInput'],
856856
},
@@ -1102,7 +1102,7 @@ describe('Execute: Handles inputs', () => {
11021102
errors: [
11031103
{
11041104
message:
1105-
'Argument "input" has invalid value: String cannot represent a non string value: WRONG_TYPE',
1105+
'Argument "TestType.fieldWithDefaultArgumentValue(input:)" has invalid value: String cannot represent a non string value: WRONG_TYPE',
11061106
locations: [{ line: 3, column: 48 }],
11071107
path: ['fieldWithDefaultArgumentValue'],
11081108
},

src/execution/values.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import type {
1414
import { Kind } from '../language/kinds.js';
1515

1616
import type { GraphQLArgument, GraphQLField } from '../type/definition.js';
17-
import { isNonNullType, isRequiredArgument } from '../type/definition.js';
17+
import {
18+
isArgument,
19+
isNonNullType,
20+
isRequiredArgument,
21+
} from '../type/definition.js';
1822
import type { GraphQLDirective } from '../type/directives.js';
1923
import type { GraphQLSchema } from '../type/schema.js';
2024

@@ -222,7 +226,7 @@ export function experimentalGetArgumentValues(
222226
// execution. This is a runtime check to ensure execution does not
223227
// continue with an invalid argument value.
224228
throw new GraphQLError(
225-
`Argument "${argDef.name}" of required type "${argType}" was not provided.`,
229+
`Argument "${isArgument(argDef) ? argDef : argDef.name}" of required type "${argType}" was not provided.`,
226230
{ nodes: node },
227231
);
228232
}
@@ -272,7 +276,7 @@ export function experimentalGetArgumentValues(
272276
valueNode,
273277
argType,
274278
(error, path) => {
275-
error.message = `Argument "${argDef.name}" has invalid value${printPathArray(
279+
error.message = `Argument "${isArgument(argDef) ? argDef : argDef.name}" has invalid value${printPathArray(
276280
path,
277281
)}: ${error.message}`;
278282
throw error;

src/index.ts

+14-17
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,15 @@ export type { GraphQLArgs } from './graphql.js';
3434
export { graphql, graphqlSync } from './graphql.js';
3535

3636
// Create and operate on GraphQL type definitions and schema.
37+
export type {
38+
GraphQLField,
39+
GraphQLArgument,
40+
GraphQLEnumValue,
41+
GraphQLInputField,
42+
} from './type/index.js';
3743
export {
3844
resolveObjMapThunk,
3945
resolveReadonlyArrayThunk,
40-
// Definitions
4146
GraphQLSchema,
4247
GraphQLDirective,
4348
GraphQLScalarType,
@@ -48,17 +53,14 @@ export {
4853
GraphQLInputObjectType,
4954
GraphQLList,
5055
GraphQLNonNull,
51-
// Standard GraphQL Scalars
5256
specifiedScalarTypes,
5357
GraphQLInt,
5458
GraphQLFloat,
5559
GraphQLString,
5660
GraphQLBoolean,
5761
GraphQLID,
58-
// Int boundaries constants
5962
GRAPHQL_MAX_INT,
6063
GRAPHQL_MIN_INT,
61-
// Built-in Directives defined by the Spec
6264
specifiedDirectives,
6365
GraphQLIncludeDirective,
6466
GraphQLSkipDirective,
@@ -67,11 +69,8 @@ export {
6769
GraphQLDeprecatedDirective,
6870
GraphQLSpecifiedByDirective,
6971
GraphQLOneOfDirective,
70-
// "Enum" of Type Kinds
7172
TypeKind,
72-
// Constant Deprecation Reason
7373
DEFAULT_DEPRECATION_REASON,
74-
// GraphQL Types for introspection.
7574
introspectionTypes,
7675
__Schema,
7776
__Directive,
@@ -81,20 +80,22 @@ export {
8180
__InputValue,
8281
__EnumValue,
8382
__TypeKind,
84-
// Meta-field definitions.
8583
SchemaMetaFieldDef,
8684
TypeMetaFieldDef,
8785
TypeNameMetaFieldDef,
88-
// Predicates
8986
isSchema,
9087
isDirective,
9188
isType,
9289
isScalarType,
9390
isObjectType,
91+
isField,
92+
isArgument,
9493
isInterfaceType,
9594
isUnionType,
9695
isEnumType,
96+
isEnumValue,
9797
isInputObjectType,
98+
isInputField,
9899
isListType,
99100
isNonNullType,
100101
isInputType,
@@ -110,16 +111,19 @@ export {
110111
isSpecifiedScalarType,
111112
isIntrospectionType,
112113
isSpecifiedDirective,
113-
// Assertions
114114
assertSchema,
115115
assertDirective,
116116
assertType,
117117
assertScalarType,
118118
assertObjectType,
119+
assertField,
120+
assertArgument,
119121
assertInterfaceType,
120122
assertUnionType,
121123
assertEnumType,
124+
assertEnumValue,
122125
assertInputObjectType,
126+
assertInputField,
123127
assertListType,
124128
assertNonNullType,
125129
assertInputType,
@@ -130,13 +134,10 @@ export {
130134
assertWrappingType,
131135
assertNullableType,
132136
assertNamedType,
133-
// Un-modifiers
134137
getNullableType,
135138
getNamedType,
136-
// Validate GraphQL schema.
137139
validateSchema,
138140
assertValidSchema,
139-
// Upholds the spec rules about naming.
140141
assertName,
141142
assertEnumValueName,
142143
} from './type/index.js';
@@ -161,23 +162,19 @@ export type {
161162
GraphQLSchemaExtensions,
162163
GraphQLDirectiveConfig,
163164
GraphQLDirectiveExtensions,
164-
GraphQLArgument,
165165
GraphQLArgumentConfig,
166166
GraphQLArgumentExtensions,
167167
GraphQLEnumTypeConfig,
168168
GraphQLEnumTypeExtensions,
169-
GraphQLEnumValue,
170169
GraphQLEnumValueConfig,
171170
GraphQLEnumValueConfigMap,
172171
GraphQLEnumValueExtensions,
173-
GraphQLField,
174172
GraphQLFieldConfig,
175173
GraphQLFieldConfigArgumentMap,
176174
GraphQLFieldConfigMap,
177175
GraphQLFieldExtensions,
178176
GraphQLFieldMap,
179177
GraphQLFieldResolver,
180-
GraphQLInputField,
181178
GraphQLInputFieldConfig,
182179
GraphQLInputFieldConfigMap,
183180
GraphQLInputFieldExtensions,

0 commit comments

Comments
 (0)