Skip to content

Commit f505c54

Browse files
committed
use @hayes naming suggestion
Co-authored-by: Michael Hayes <[email protected]>"
1 parent 289de46 commit f505c54

25 files changed

+134
-179
lines changed

integrationTests/ts/basic-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const queryType: GraphQLObjectType = new GraphQLObjectType({
1111
args: {
1212
who: {
1313
type: GraphQLString,
14-
externalDefaultValue: 'World',
14+
default: { value: 'World' },
1515
},
1616
},
1717
resolve(_root, args: { who: string }) {

integrationTests/ts/esm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const queryType: GraphQLObjectType = new GraphQLObjectType({
1515
args: {
1616
who: {
1717
type: GraphQLString,
18-
externalDefaultValue: 'World',
18+
default: { value: 'World' },
1919
},
2020
},
2121
resolve(_root, args: { who: string }) {

src/execution/__tests__/executor-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ describe('Execute: Handles basic execution tasks', () => {
246246
signature: {
247247
name: 'var',
248248
type: GraphQLString,
249-
externalDefaultValue: undefined,
249+
default: undefined,
250250
},
251251
value: 'abc',
252252
},

src/execution/__tests__/variables-test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ const TestType = new GraphQLObjectType({
142142
}),
143143
fieldWithDefaultArgumentValue: fieldWithInputArg({
144144
type: GraphQLString,
145-
externalDefaultValue: 'Hello World',
145+
default: { value: 'Hello World' },
146146
}),
147147
fieldWithNonNullableStringInputAndDefaultArgumentValue: fieldWithInputArg({
148148
type: new GraphQLNonNull(GraphQLString),
149-
externalDefaultValue: 'Hello World',
149+
default: { value: 'Hello World' },
150150
}),
151151
fieldWithNestedInputObject: fieldWithInputArg({
152152
type: TestNestedInputObject,
@@ -187,7 +187,7 @@ const schema = new GraphQLSchema({
187187
type: new GraphQLNonNull(GraphQLBoolean),
188188
description: 'Skipped when true.',
189189
// default values will override operation variables in the setting of defined fragment variables that are not provided
190-
externalDefaultValue: true,
190+
default: { value: true },
191191
},
192192
},
193193
}),

src/execution/getVariableSignature.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface GraphQLVariableSignature {
2121
name: string;
2222
type: GraphQLInputType;
2323
defaultValue?: never;
24-
externalDefaultValue: { literal: ConstValueNode } | undefined;
24+
default: { literal: ConstValueNode } | undefined;
2525
}
2626

2727
export function getVariableSignature(
@@ -46,6 +46,6 @@ export function getVariableSignature(
4646
return {
4747
name: varName,
4848
type: varType,
49-
externalDefaultValue: defaultValue ? { literal: defaultValue } : undefined,
49+
default: defaultValue && { literal: defaultValue },
5050
};
5151
}

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export type {
212212
GraphQLScalarOutputValueCoercer,
213213
GraphQLScalarInputValueCoercer,
214214
GraphQLScalarInputLiteralCoercer,
215-
GraphQLDefaultValueUsage,
215+
GraphQLDefaultInput,
216216
} from './type/index.js';
217217

218218
// Parse and operate on GraphQL language source files.

src/type/__tests__/definition-test.ts

+10-29
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ describe('Type System: Objects', () => {
205205
description: 'Argument description.',
206206
type: ScalarType,
207207
defaultValue: undefined,
208-
externalDefaultValue: 'DefaultValue',
209-
defaultValueLiteral: undefined,
208+
default: { value: 'DefaultValue' },
210209
deprecationReason: 'Argument deprecation reason.',
211210
extensions: { someExtension: 'extension' },
212211
astNode: dummyAny,
@@ -378,7 +377,7 @@ describe('Type System: Objects', () => {
378377
description: undefined,
379378
type: ScalarType,
380379
defaultValue: undefined,
381-
externalDefaultValue: undefined,
380+
default: undefined,
382381
deprecationReason: undefined,
383382
extensions: {},
384383
astNode: undefined,
@@ -495,8 +494,7 @@ describe('Type System: Interfaces', () => {
495494
description: 'Argument description.',
496495
type: ScalarType,
497496
defaultValue: undefined,
498-
externalDefaultValue: undefined,
499-
defaultValueLiteral: dummyAny,
497+
default: { literal: dummyAny },
500498
deprecationReason: 'Argument deprecation reason.',
501499
extensions: { someExtension: 'extension' },
502500
astNode: dummyAny,
@@ -834,8 +832,7 @@ describe('Type System: Input Objects', () => {
834832
description: 'Argument description.',
835833
type: ScalarType,
836834
defaultValue: undefined,
837-
externalDefaultValue: 'DefaultValue',
838-
defaultValueLiteral: undefined,
835+
default: { value: 'DefaultValue' },
839836
deprecationReason: 'Argument deprecation reason.',
840837
extensions: { someExtension: 'extension' },
841838
astNode: dummyAny,
@@ -864,7 +861,7 @@ describe('Type System: Input Objects', () => {
864861
description: undefined,
865862
type: ScalarType,
866863
defaultValue: undefined,
867-
externalDefaultValue: undefined,
864+
default: undefined,
868865
deprecationReason: undefined,
869866
extensions: {},
870867
astNode: undefined,
@@ -884,7 +881,7 @@ describe('Type System: Input Objects', () => {
884881
description: undefined,
885882
type: ScalarType,
886883
defaultValue: undefined,
887-
externalDefaultValue: undefined,
884+
default: undefined,
888885
extensions: {},
889886
deprecationReason: undefined,
890887
astNode: undefined,
@@ -933,15 +930,15 @@ describe('Type System: Input Objects', () => {
933930
const inputObjType = new GraphQLInputObjectType({
934931
name: 'SomeInputObject',
935932
fields: {
936-
f: { type: ScalarType, externalDefaultValue: 3 },
933+
f: { type: ScalarType, default: { value: 3 } },
937934
},
938935
});
939936
expect(inputObjType.getFields().f).to.deep.include({
940937
name: 'f',
941938
description: undefined,
942939
type: ScalarType,
943940
defaultValue: undefined,
944-
externalDefaultValue: { value: 3 },
941+
default: { value: 3 },
945942
deprecationReason: undefined,
946943
extensions: {},
947944
astNode: undefined,
@@ -954,7 +951,7 @@ describe('Type System: Input Objects', () => {
954951
fields: {
955952
f: {
956953
type: ScalarType,
957-
defaultValueLiteral: { kind: Kind.INT, value: '3' },
954+
default: { literal: { kind: Kind.INT, value: '3' } },
958955
},
959956
},
960957
});
@@ -963,28 +960,12 @@ describe('Type System: Input Objects', () => {
963960
description: undefined,
964961
type: ScalarType,
965962
defaultValue: undefined,
966-
externalDefaultValue: { literal: { kind: 'IntValue', value: '3' } },
963+
default: { literal: { kind: 'IntValue', value: '3' } },
967964
deprecationReason: undefined,
968965
extensions: {},
969966
astNode: undefined,
970967
});
971968
});
972-
973-
it('rejects an Input Object type with potentially conflicting default values', () => {
974-
const inputObjType = new GraphQLInputObjectType({
975-
name: 'SomeInputObject',
976-
fields: {
977-
f: {
978-
type: ScalarType,
979-
externalDefaultValue: 3,
980-
defaultValueLiteral: { kind: Kind.INT, value: '3' },
981-
},
982-
},
983-
});
984-
expect(() => inputObjType.getFields()).to.throw(
985-
'Argument "f" has both an externalDefaultValue and a defaultValueLiteral property, but only one must be provided.',
986-
);
987-
});
988969
});
989970
});
990971

src/type/__tests__/directive-test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('Type System: Directive', () => {
4545
description: undefined,
4646
type: GraphQLString,
4747
defaultValue: undefined,
48-
externalDefaultValue: undefined,
48+
default: undefined,
4949
deprecationReason: undefined,
5050
extensions: {},
5151
astNode: undefined,
@@ -57,7 +57,7 @@ describe('Type System: Directive', () => {
5757
description: undefined,
5858
type: GraphQLInt,
5959
defaultValue: undefined,
60-
externalDefaultValue: undefined,
60+
default: undefined,
6161
deprecationReason: undefined,
6262
extensions: {},
6363
astNode: undefined,

src/type/__tests__/enumType-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const QueryType = new GraphQLObjectType({
7171
args: {
7272
fromEnum: {
7373
type: ComplexEnum,
74-
externalDefaultValue: 'ONE',
74+
default: { value: 'ONE' },
7575
},
7676
provideGoodValue: { type: GraphQLBoolean },
7777
provideBadValue: { type: GraphQLBoolean },

src/type/__tests__/predicate-test.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { DirectiveLocation } from '../../language/directiveLocation.js';
55

66
import type {
77
GraphQLArgument,
8+
GraphQLDefaultInput,
89
GraphQLInputField,
910
GraphQLInputType,
1011
} from '../definition.js';
@@ -634,7 +635,7 @@ describe('Type predicates', () => {
634635
describe('isRequiredArgument', () => {
635636
function buildArg(config: {
636637
type: GraphQLInputType;
637-
externalDefaultValue?: unknown;
638+
default?: GraphQLDefaultInput;
638639
}): GraphQLArgument {
639640
const objectType = new GraphQLObjectType({
640641
name: 'SomeType',
@@ -660,7 +661,7 @@ describe('Type predicates', () => {
660661

661662
const optArg2 = buildArg({
662663
type: GraphQLString,
663-
externalDefaultValue: null,
664+
default: { value: null },
664665
});
665666
expect(isRequiredArgument(optArg2)).to.equal(false);
666667

@@ -671,7 +672,7 @@ describe('Type predicates', () => {
671672

672673
const optArg4 = buildArg({
673674
type: new GraphQLNonNull(GraphQLString),
674-
externalDefaultValue: 'default',
675+
default: { value: 'default' },
675676
});
676677
expect(isRequiredArgument(optArg4)).to.equal(false);
677678
});
@@ -680,7 +681,7 @@ describe('Type predicates', () => {
680681
describe('isRequiredInputField', () => {
681682
function buildInputField(config: {
682683
type: GraphQLInputType;
683-
externalDefaultValue?: unknown;
684+
default?: GraphQLDefaultInput;
684685
}): GraphQLInputField {
685686
const inputObjectType = new GraphQLInputObjectType({
686687
name: 'SomeType',
@@ -706,7 +707,7 @@ describe('Type predicates', () => {
706707

707708
const optField2 = buildInputField({
708709
type: GraphQLString,
709-
externalDefaultValue: null,
710+
default: { value: null },
710711
});
711712
expect(isRequiredInputField(optField2)).to.equal(false);
712713

@@ -717,7 +718,7 @@ describe('Type predicates', () => {
717718

718719
const optField4 = buildInputField({
719720
type: new GraphQLNonNull(GraphQLString),
720-
externalDefaultValue: 'default',
721+
default: { value: 'default' },
721722
});
722723
expect(isRequiredInputField(optField4)).to.equal(false);
723724
});

0 commit comments

Comments
 (0)