-
Notifications
You must be signed in to change notification settings - Fork 362
fix: allow modifying GraphQLInterfaceType in the willAddGraphQLTypeToSchema hook #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow modifying GraphQLInterfaceType in the willAddGraphQLTypeToSchema hook #293
Conversation
877a45f
to
09f9c3b
Compare
Codecov Report
@@ Coverage Diff @@
## master #293 +/- ##
============================================
- Coverage 64.57% 64.56% -0.01%
+ Complexity 195 194 -1
============================================
Files 103 103
Lines 1067 1064 -3
Branches 153 152 -1
============================================
- Hits 689 687 -2
+ Misses 364 363 -1
Partials 14 14
Continue to review full report at Codecov.
|
…Schema 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: ExpediaGroup#281
09f9c3b
to
4b6c3da
Compare
assertEquals("SomeData!", hooks.lastSeenGeneratedType?.deepName) | ||
assertTrue(hooks.seenTypes.contains(RandomData::class.createType())) | ||
assertTrue(hooks.seenTypes.contains(SomeData::class.createType())) | ||
// TODO bug: didGenerateGraphQLType hook is not applied on the object types build from the interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO intended here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes -> it is a bug in how we apply the hooks... :(
...otlin-schema-generator/src/test/kotlin/com/expedia/graphql/hooks/SchemaGeneratorHooksTest.kt
Outdated
Show resolved
Hide resolved
eeea8b7
to
e0f50df
Compare
…Schema hook (ExpediaGroup#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: ExpediaGroup#281 * update test to verify hook updates interface description
…Schema hook (ExpediaGroup#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: ExpediaGroup#281 * update test to verify hook updates interface description
InterfaceBuilder attempts to create all the implementing
GraphQLObjectType
s after building an interface but before executing thewillAddGraphQLTypeToSchema
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 referencingGraphQLInterfaceType
from theGraphQLObjectType
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