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
extend remote schema input type error #1177
Comments
Currently, mergeSchemas filters on delegation to remove output type fields added to selection set by extend, but does not filter out fields added by extend on input types. Workaround is to manually create a delegating resolver from your root field to the original field and filter the args parameter on your own. This should not be too much extra work as presumably you would have a manual delegating resolver for the root field already to take an advantage of whatever input field you added on extend. |
sorry. would u mind share more details? Thanks |
Sure. Why don't you start by describing what you are trying to accomplish by extending an input field. |
Yes, I need to add a field in PostInput, so I can get this to save on my local database |
It sounds like what you are trying to do is delegate your local addPost mutation to the remote schema, but also save additional metadata about the post to your local database. mergeSchemas automatically provides for you a resolver that will delegate your local addPost mutation to the remote: It looks like this (see https://github.com/apollographql/graphql-tools/blob/master/src/stitching/mergeSchemas.ts#L392)
If you want a root field like addPost to do something more than just simple delegating, you will have to override the above resolver with your own in your call to mergeSchemas. So what looks like this (https://github.com/mrdulin/apollo-graphql-tutorial/blob/master/src/extend-remote-schema/service-2/server.ts#L15)
should end up looking something like this:
This will still fail. At this point, delegateToSchemas is not smart enough to strip out the fields you add to your input types prior to delegation. But the workaround is to do that manually:
where you also define a new function:
|
Actually, I am not sure this is the issue. Will have to try example above. What exact query are you sending with that variable value? |
I think the problem is that the other fields in postInput are required. Closing for now, feel free to reopen as necessary. |
my remote schema:
My extend schema
this is the demo code:
https://github.com/mrdulin/apollo-graphql-tutorial/tree/master/src/extend-remote-schema
on my playgroud I can see my schema but when I call this the error is :
"Variable "$_v0_input" got invalid value "
Anyone can help this?
The text was updated successfully, but these errors were encountered: