Commit 4d62752
fix: allow modifying GraphQLInterfaceType in the willAddGraphQLTypeToSchema hook (#293)
* fix: allow modifying GraphQLInterfaceType in the willAddGraphQLTypeToSchema hook
InterfaceBuilder attempts to create all the implementing `GraphQLObjectType`s after building an interface but before executing the `willAddGraphQLTypeToSchema` hook. This means that if we attempt to update the interface in that hook there could be some objects implementing that interface and referencing the old one. Since graphql-java schema objects don't implement hashcode we end up with type conflict of two interfaces being defined in the schema.
Fix is to use `GraphQLTypeReference` when referencing `GraphQLInterfaceType` from the `GraphQLObjectType` builder. Reference is just by name and they are resolved as the last step of building a schema. This allows us to modify the interface in the hook.
Resolves: #281
* update test to verify hook updates interface description1 parent 10da005 commit 4d62752
File tree
5 files changed
+34
-46
lines changed- graphql-kotlin-schema-generator/src
- main/kotlin/com/expedia/graphql/generator/types
- test/kotlin/com/expedia/graphql/hooks
5 files changed
+34
-46
lines changedLines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
44 | | - | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
36 | 34 | | |
37 | 35 | | |
38 | 36 | | |
| |||
Lines changed: 0 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | | - | |
34 | | - | |
35 | 32 | | |
36 | 33 | | |
37 | 34 | | |
38 | 35 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | 36 | | |
44 | 37 | | |
45 | 38 | | |
| |||
Lines changed: 30 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | 45 | | |
66 | 46 | | |
67 | 47 | | |
| |||
106 | 86 | | |
107 | 87 | | |
108 | 88 | | |
109 | | - | |
110 | | - | |
| 89 | + | |
111 | 90 | | |
112 | | - | |
113 | | - | |
| 91 | + | |
114 | 92 | | |
115 | 93 | | |
116 | 94 | | |
| |||
120 | 98 | | |
121 | 99 | | |
122 | 100 | | |
123 | | - | |
124 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
125 | 105 | | |
126 | 106 | | |
127 | 107 | | |
| |||
132 | 112 | | |
133 | 113 | | |
134 | 114 | | |
135 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
136 | 118 | | |
137 | 119 | | |
138 | 120 | | |
| |||
148 | 130 | | |
149 | 131 | | |
150 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
151 | 137 | | |
152 | 138 | | |
153 | 139 | | |
| |||
161 | 147 | | |
162 | 148 | | |
163 | 149 | | |
164 | | - | |
| 150 | + | |
165 | 151 | | |
166 | 152 | | |
167 | 153 | | |
| |||
187 | 173 | | |
188 | 174 | | |
189 | 175 | | |
190 | | - | |
| 176 | + | |
191 | 177 | | |
192 | 178 | | |
193 | 179 | | |
| |||
212 | 198 | | |
213 | 199 | | |
214 | 200 | | |
215 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
216 | 211 | | |
217 | 212 | | |
218 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
219 | 216 | | |
0 commit comments