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
@@ -55,11 +53,14 @@ class MyType : MyTypeInterface() {
55
53
As you can see, the generated code is not part of the implementation. Rather, it becomes an interface to inherit from in your implementation.
56
54
This enforces a type contract between the schema and your resolver code.
57
55
58
-
## Top Level Types
56
+
Note that GraphQL Kotlin will use the implementation classes to generate the schema, not the generated interfaces.
57
+
This means that all `@GraphQLDescription` and `@Deprecated` annotations have to be added to implementation classes
58
+
in order to be propagated to the resulting schema.
59
59
60
-
When dealing with top-level types, such as `Query` or `Mutation`, you can inherit from the generated class directly. This is because the generated class is open by default.
60
+
## Top Level Types
61
61
62
-
Given the following executable schema:
62
+
When dealing with top-level types, i.e. `Query` and `Mutation`, you can inherit from the corresponding generated class
63
+
to enforce the type contract. This is fine as long as all of your resolvers are contained in the same Query or Mutation class.
@@ -97,7 +108,7 @@ class BarQuery : Query, QueryInterface() {
97
108
}
98
109
```
99
110
100
-
This is because the generated `Query` class contains both `foo` and `bar` fields, which causes a conflict when inherited by multiple implementation classes.
111
+
This is because the generated `Query` class contains both `foo` and `bar` fields, which creates a conflict when inherited by multiple implementation classes.
101
112
102
113
Instead, you should inherit from the field-level generated `Query` classes like so:
103
114
@@ -114,3 +125,5 @@ class BarQuery : Query, BarQueryInterface() {
114
125
overridefunbar(): String="World"
115
126
}
116
127
```
128
+
129
+
This way, schema generation can complete without conflict, and you can separate your implementation into multiple classes!
0 commit comments