Add support for custom enum resolvers and scalar types#1345
Add support for custom enum resolvers and scalar types#1345trevor-scheer merged 7 commits intoapollographql:masterfrom
Conversation
|
Thanks! This feels much better. Ping @trevor-scheer to ask if this is a bad idea for any reason. |
|
Hey @hannesj, firstly thank you for the details and the contribution. Your analysis and approach are perfectly reasonable.
Apologies that this isn't documented or explained anywhere yet, but I'd like to add some additional context so this isn't coming out of nowhere. GraphQL tools includes two major things:
We're currently working with maintainers of With Federation, we're moving away from stitching. Since many teams still rely on stitching, we want to make the |
e5ce9ea to
4fa08ae
Compare
|
Hi, I rebased this based on feedback from you, leaving out the adding of the dependency, and using the previous commits. Unfortunately it seems that the solution for renaming the enums was not enough, as the lastly added test now fails. |
|
|
||
| // In place updating hack to get around pulling in the full | ||
| // schema walking and immutable updating machinery from graphql-tools | ||
| Object.assign( |
There was a problem hiding this comment.
@trevor-scheer what do you think of this? At first I tried copying direct from grapql-tools, but it ended up requiring a lot more dependencies than I expected. (https://github.com/apollographql/graphql-tools/blob/master/src/transforms/ConvertEnumValues.ts#L10, which requires https://github.com/apollographql/graphql-tools/blob/master/src/transforms/visitSchema.ts#L38, which requires https://github.com/apollographql/graphql-tools/blob/master/src/stitching/schemaRecreation.ts#L27, etc.)
trevor-scheer
left a comment
There was a problem hiding this comment.
This looks good to me, I'd like @jbaxleyiii to give approval on the approach in case there's any nuance I'm overlooking.
|
Thank you both for this @hannesj and @JacksonKearl! 🎉 |
As described in #1343 and #1344, it is better to use
addResolveFunctionsToSchemafrom graphql-tools to add the resolvers to the new schema, as it is how the resolvers are added normally in apolo-server, so that both scalars and enums are handled properly. As a TODO, it might be sensible to use more functionality from https://github.com/apollographql/graphql-tools/blob/84e77ac7d7e06f149019c5a42dd2e86907e27ac1/src/makeExecutableSchema.ts when generating the new schema.TODO:
*Make sure changelog entries note which project(s) has been affected. See older entries for examples on what this looks like.