Skip to content

Commit 9ab0dfe

Browse files
test: Adds ComplexInput & OneOfInput to example schema
1 parent 7a73e85 commit 9ab0dfe

File tree

1 file changed

+193
-0
lines changed

1 file changed

+193
-0
lines changed

Tests/GraphQLTests/ValidationTests/ExampleSchema.swift

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,198 @@ let ValidationExampleHumanOrAlien = try! GraphQLUnionType(
376376
types: [ValidationExampleHuman, ValidationExampleAlien]
377377
)
378378

379+
// input ComplexInput {
380+
// requiredField: Boolean!
381+
// nonNullField: Boolean! = false
382+
// intField: Int
383+
// stringField: String
384+
// booleanField: Boolean
385+
// stringListField: [String]
386+
// }
387+
let ValidationExampleComplexInput = try! GraphQLInputObjectType(
388+
name: "ComplexInput",
389+
fields: [
390+
"requiredField": InputObjectField(type: GraphQLNonNull(GraphQLBoolean)),
391+
"nonNullField": InputObjectField(type: GraphQLNonNull(GraphQLBoolean), defaultValue: false),
392+
"intField": InputObjectField(type: GraphQLInt),
393+
"stringField": InputObjectField(type: GraphQLString),
394+
"booleanField": InputObjectField(type: GraphQLBoolean),
395+
"stringListField": InputObjectField(type: GraphQLList(GraphQLString)),
396+
]
397+
)
398+
399+
// input OneOfInput @oneOf {
400+
// stringField: String
401+
// intField: Int
402+
// }
403+
let ValidationExampleOneOfInput = try! GraphQLInputObjectType(
404+
name: "OneOfInput",
405+
// TODO: Add @oneOf directive
406+
fields: [
407+
"stringField": InputObjectField(type: GraphQLBoolean),
408+
"intField": InputObjectField(type: GraphQLInt),
409+
]
410+
)
411+
412+
// type ComplicatedArgs {
413+
// # TODO List
414+
// # TODO Coercion
415+
// # TODO NotNulls
416+
// intArgField(intArg: Int): String
417+
// nonNullIntArgField(nonNullIntArg: Int!): String
418+
// stringArgField(stringArg: String): String
419+
// booleanArgField(booleanArg: Boolean): String
420+
// enumArgField(enumArg: FurColor): String
421+
// floatArgField(floatArg: Float): String
422+
// idArgField(idArg: ID): String
423+
// stringListArgField(stringListArg: [String]): String
424+
// stringListNonNullArgField(stringListNonNullArg: [String!]): String
425+
// complexArgField(complexArg: ComplexInput): String
426+
// oneOfArgField(oneOfArg: OneOfInput): String
427+
// multipleReqs(req1: Int!, req2: Int!): String
428+
// nonNullFieldWithDefault(arg: Int! = 0): String
429+
// multipleOpts(opt1: Int = 0, opt2: Int = 0): String
430+
// multipleOptAndReq(req1: Int!, req2: Int!, opt1: Int = 0, opt2: Int = 0): String
431+
// }
432+
let ValidationExampleComplicatedArgs = try! GraphQLObjectType(
433+
name: "ComplicatedArgs",
434+
fields: [
435+
"intArgField": GraphQLField(
436+
type: GraphQLString,
437+
args: ["intArg": GraphQLArgument(type: GraphQLInt)],
438+
resolve: { inputValue, _, _, _ -> String? in
439+
print(type(of: inputValue))
440+
return nil
441+
}
442+
),
443+
"nonNullIntArgField": GraphQLField(
444+
type: GraphQLString,
445+
args: ["nonNullIntArg": GraphQLArgument(type: GraphQLNonNull(GraphQLInt))],
446+
resolve: { inputValue, _, _, _ -> String? in
447+
print(type(of: inputValue))
448+
return nil
449+
}
450+
),
451+
"stringArgField": GraphQLField(
452+
type: GraphQLString,
453+
args: ["stringArg": GraphQLArgument(type: GraphQLString)],
454+
resolve: { inputValue, _, _, _ -> String? in
455+
print(type(of: inputValue))
456+
return nil
457+
}
458+
),
459+
"booleanArgField": GraphQLField(
460+
type: GraphQLString,
461+
args: ["booleanArg": GraphQLArgument(type: GraphQLBoolean)],
462+
resolve: { inputValue, _, _, _ -> String? in
463+
print(type(of: inputValue))
464+
return nil
465+
}
466+
),
467+
"enumArgField": GraphQLField(
468+
type: GraphQLString,
469+
args: ["enumArg": GraphQLArgument(type: ValidationExampleFurColor)],
470+
resolve: { inputValue, _, _, _ -> String? in
471+
print(type(of: inputValue))
472+
return nil
473+
}
474+
),
475+
"floatArgField": GraphQLField(
476+
type: GraphQLString,
477+
args: ["floatArg": GraphQLArgument(type: GraphQLFloat)],
478+
resolve: { inputValue, _, _, _ -> String? in
479+
print(type(of: inputValue))
480+
return nil
481+
}
482+
),
483+
"idArgField": GraphQLField(
484+
type: GraphQLString,
485+
args: ["idArg": GraphQLArgument(type: GraphQLID)],
486+
resolve: { inputValue, _, _, _ -> String? in
487+
print(type(of: inputValue))
488+
return nil
489+
}
490+
),
491+
"stringListArgField": GraphQLField(
492+
type: GraphQLString,
493+
args: ["stringListArg": GraphQLArgument(type: GraphQLList(GraphQLString))],
494+
resolve: { inputValue, _, _, _ -> String? in
495+
print(type(of: inputValue))
496+
return nil
497+
}
498+
),
499+
"stringListNonNullArgField": GraphQLField(
500+
type: GraphQLString,
501+
args: [
502+
"stringListNonNullArg": GraphQLArgument(type: GraphQLList(GraphQLNonNull(GraphQLString))),
503+
],
504+
resolve: { inputValue, _, _, _ -> String? in
505+
print(type(of: inputValue))
506+
return nil
507+
}
508+
),
509+
"complexArgField": GraphQLField(
510+
type: GraphQLString,
511+
args: ["complexArg": GraphQLArgument(type: ValidationExampleComplexInput)],
512+
resolve: { inputValue, _, _, _ -> String? in
513+
print(type(of: inputValue))
514+
return nil
515+
}
516+
),
517+
"oneOfArgField": GraphQLField(
518+
type: GraphQLString,
519+
args: ["oneOfArg": GraphQLArgument(type: ValidationExampleOneOfInput)],
520+
resolve: { inputValue, _, _, _ -> String? in
521+
print(type(of: inputValue))
522+
return nil
523+
}
524+
),
525+
"multipleReqs": GraphQLField(
526+
type: GraphQLString,
527+
args: [
528+
"req1": GraphQLArgument(type: GraphQLNonNull(GraphQLInt)),
529+
"req2": GraphQLArgument(type: GraphQLNonNull(GraphQLInt)),
530+
],
531+
resolve: { inputValue, _, _, _ -> String? in
532+
print(type(of: inputValue))
533+
return nil
534+
}
535+
),
536+
"nonNullFieldWithDefault": GraphQLField(
537+
type: GraphQLString,
538+
args: ["arg": GraphQLArgument(type: GraphQLNonNull(GraphQLInt), defaultValue: 0)],
539+
resolve: { inputValue, _, _, _ -> String? in
540+
print(type(of: inputValue))
541+
return nil
542+
}
543+
),
544+
"multipleOpts": GraphQLField(
545+
type: GraphQLString,
546+
args: [
547+
"opt1": GraphQLArgument(type: GraphQLInt, defaultValue: 0),
548+
"opt2": GraphQLArgument(type: GraphQLInt, defaultValue: 0),
549+
],
550+
resolve: { inputValue, _, _, _ -> String? in
551+
print(type(of: inputValue))
552+
return nil
553+
}
554+
),
555+
"multipleOptAndReq": GraphQLField(
556+
type: GraphQLString,
557+
args: [
558+
"req1": GraphQLArgument(type: GraphQLNonNull(GraphQLInt)),
559+
"req2": GraphQLArgument(type: GraphQLNonNull(GraphQLInt)),
560+
"opt1": GraphQLArgument(type: GraphQLInt, defaultValue: 0),
561+
"opt2": GraphQLArgument(type: GraphQLInt, defaultValue: 0),
562+
],
563+
resolve: { inputValue, _, _, _ -> String? in
564+
print(type(of: inputValue))
565+
return nil
566+
}
567+
),
568+
]
569+
)
570+
379571
// type QueryRoot {
380572
// dog: Dog
381573
// }
@@ -391,6 +583,7 @@ let ValidationExampleQueryRoot = try! GraphQLObjectType(
391583
return nil
392584
},
393585
"humanOrAlien": GraphQLField(type: ValidationExampleHumanOrAlien),
586+
"complicatedArgs": GraphQLField(type: ValidationExampleComplicatedArgs),
394587
]
395588
)
396589

0 commit comments

Comments
 (0)