@@ -37,17 +37,40 @@ class GraphQLSchema:
37
37
38
38
Example::
39
39
40
- const MyAppSchema = GraphQLSchema(
40
+ MyAppSchema = GraphQLSchema(
41
41
query=MyAppQueryRootType,
42
42
mutation=MyAppMutationRootType)
43
43
44
+ Note: When the schema is constructed, by default only the types that are
45
+ reachable by traversing the root types are included, other types must be
46
+ explicitly referenced.
47
+
48
+ Example::
49
+
50
+ character_interface = GraphQLInterfaceType('Character', ...)
51
+
52
+ human_type = GraphQLObjectType(
53
+ 'Human', interfaces=[character_interface], ...)
54
+
55
+ droid_type = GraphQLObjectType(
56
+ 'Droid', interfaces: [character_interface], ...)
57
+
58
+ schema = GraphQLSchema(
59
+ query=GraphQLObjectType('Query',
60
+ fields={'hero': GraphQLField(character_interface, ....)}),
61
+ ...
62
+ # Since this schema references only the `Character` interface it's
63
+ # necessary to explicitly list the types that implement it if
64
+ # you want them to be included in the final schema.
65
+ types=[human_type, droid_type])
66
+
44
67
Note: If a list of `directives` are provided to GraphQLSchema, that will be the
45
68
exact list of directives represented and allowed. If `directives` is not provided,
46
69
then a default set of the specified directives (e.g. @include and @skip) will be
47
70
used. If you wish to provide *additional* directives to these specified directives,
48
71
you must explicitly declare them. Example::
49
72
50
- const MyAppSchema = GraphQLSchema(
73
+ MyAppSchema = GraphQLSchema(
51
74
...
52
75
directives=specifiedDirectives + [myCustomDirective])
53
76
"""
0 commit comments