You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'Query.field(argWithPossibleFix:) has invalid default value: { self: null, string: [1], enum: 2 }. Did you mean: { self: null, string: ["1"], enum: "TWO" }?',
1957
+
},
1958
+
{
1959
+
message:
1960
+
'Query.field(argWithInvalidPossibleFix:) has invalid default value at .string: Expected value of non-null type "[String]!" not to be null.',
1961
+
},
1962
+
{
1963
+
message:
1964
+
'Query.field(argWithoutPossibleFix:) has invalid default value: Expected value of type "TestInput" to include required field "string", found { enum: 3 }',
1965
+
},
1966
+
{
1967
+
message:
1968
+
'Query.field(argWithoutPossibleFix:) has invalid default value at .enum: Enum "TestEnum" cannot represent non-string value: 3.',
1969
+
},
1970
+
]);
1971
+
});
1972
+
});
1973
+
1860
1974
describe('Type System: Input Object fields must have input types',()=>{
1861
1975
functionschemaWithInputField(
1862
1976
inputFieldConfig: GraphQLInputFieldConfig,
@@ -1953,6 +2067,61 @@ describe('Type System: Input Object fields must have input types', () => {
1953
2067
});
1954
2068
});
1955
2069
2070
+
describe('Type System: Input Object field default values must be valid',()=>{
2071
+
it('rejects an Input Object field with invalid default values (SDL)',()=>{
2072
+
constschema=buildSchema(`
2073
+
type Query {
2074
+
field(arg: SomeInputObject): Int
2075
+
}
2076
+
2077
+
input SomeInputObject {
2078
+
field: Int = 3.14
2079
+
}
2080
+
`);
2081
+
2082
+
expect(validateSchema(schema)).to.deep.equal([
2083
+
{
2084
+
message:
2085
+
'SomeInputObject.field has invalid default value: Int cannot represent non-integer value: 3.14',
2086
+
locations: [{line: 7,column: 20}],
2087
+
},
2088
+
]);
2089
+
});
2090
+
2091
+
it('rejects an Input Object field with invalid default values (programmatic)',()=>{
2092
+
constsomeInputObject=newGraphQLInputObjectType({
2093
+
name: 'SomeInputObject',
2094
+
fields: {
2095
+
field: {
2096
+
type: GraphQLInt,
2097
+
defaultValue: 3.14,
2098
+
},
2099
+
},
2100
+
});
2101
+
2102
+
constschema=newGraphQLSchema({
2103
+
query: newGraphQLObjectType({
2104
+
name: 'Query',
2105
+
fields: {
2106
+
field: {
2107
+
type: GraphQLInt,
2108
+
args: {
2109
+
arg: {type: someInputObject},
2110
+
},
2111
+
},
2112
+
},
2113
+
}),
2114
+
});
2115
+
2116
+
expect(validateSchema(schema)).to.deep.equal([
2117
+
{
2118
+
message:
2119
+
'SomeInputObject.field has invalid default value: Int cannot represent non-integer value: 3.14',
2120
+
},
2121
+
]);
2122
+
});
2123
+
});
2124
+
1956
2125
describe('Objects must adhere to Interface they implement',()=>{
1957
2126
it('accepts an Object which implements an Interface',()=>{
0 commit comments