feat: update graphql type informer to handle circular dependencies be…#1571
Conversation
PR Summary
|
MarcAstr0
left a comment
There was a problem hiding this comment.
The only change needed would be to work around the no longer accessible usage of defineFieldMap.
| }, {}), | ||
| Object.assign(this.graphQLTypes[typeName], { | ||
| _fields: () => | ||
| defineFieldMap({ |
There was a problem hiding this comment.
@hendrik-depauw-lemon, it appears that defineFieldMap is no longer accessible in graphql: ^16.6.0, the version used, causing the project not to build. It seems you can work around this by doing the following instead:
const inputObjectType = this.graphQLTypes[typeName] as GraphQLInputObjectType
Object.assign(inputObjectType, {
_fields: () => {
return finalFields.reduce((obj, prop) => {
this.logger.debug(`Get or create GraphQL input type for property ${prop.name}`)
return {
...obj,
[prop.name]: { type: this.getOrCreateGraphQLType(prop.typeInfo, inputType) },
}
}, {})
},
})|
|
||
| Object.assign(this.graphQLTypes[typeName], { | ||
| _fields: () => | ||
| defineFieldMap({ |
There was a problem hiding this comment.
@hendrik-depauw-lemon, it's the same thing here regarding the usage of defineFieldMap.
Description
The graphql type informer could not handle circular dependencies between types. The result would always be JSON. By using thunks, we can fix this issue.
Changes
Checks
Additional information
We are using
Object.assignon thegraphqlTypesmap so that the references to the types do not change. However, when we want to update the fields of the type, we need an internal function from the graphql package that is currently not exported. What course of action do you guys suggest? Should we open a PR to graphql? Do we patch graphql? Do we copy the internals of the function? Other options?