Skip to content
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

Make adding directives to existing fields easier when schema stitching #451

Closed
kbrandwijk opened this issue Oct 26, 2017 · 3 comments
Closed

Comments

@kbrandwijk
Copy link
Contributor

kbrandwijk commented Oct 26, 2017

When I use mergeSchemas for schema stitching, I often need to add a directive to a field (to specify cacheControl). However, I can't put the same field in two schemas, because it will give me an error if I do so. My workaround was going to be:

  • get the first schema (makeRemoteExecutableSchema)
  • call transformSchema on it to remove the existing field
  • merge with the second schema that contains the new field definition

But in that case, the field no longer 'belongs' to the first schema, so it isn't resolved correctly without delegating it back to the original field, which doesn't work when I use transformSchema to remove it first.

It would be helpful if I could set a directive on the field in my second schema, @overwrite or something, that would make this easier for me to do. Because now my only workaround is to create a field with a new name in my second schema, then do the merge, and then remove the original field using transformSchema. I don't know why, but that way my delegate keeps working! And renaming a lot of fields like this isn't really a good solution...

@kbrandwijk kbrandwijk changed the title Make overwriting fields easier when schema stitching Make adding directives to existing fields easier when schema stitching Oct 26, 2017
@yaacovCR yaacovCR mentioned this issue Mar 29, 2020
22 tasks
@yaacovCR yaacovCR reopened this Apr 3, 2020
@yaacovCR
Copy link
Collaborator

yaacovCR commented Nov 2, 2020

This maybe could be handled now with some custom fieldConfigMerger logic, https://www.graphql-tools.com/docs/stitch-type-merging

Needs to be explored....

@yaacovCR
Copy link
Collaborator

Actually I think easiest thing is to use mergeSchemas which should merge in directives...

Note that stitching function is now called stitchSchemas, so mergeSchemas just straight merges without wrapping or proxying

@ardatan ardatan closed this as completed Apr 14, 2021
@ardatan
Copy link
Owner

ardatan commented Apr 14, 2021

I think @yaacovCR is right. Feel free to create a new issue if this is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants