-
-
Notifications
You must be signed in to change notification settings - Fork 816
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
Unspecified variable is becoming null when stitching schemas #1453
Comments
Sounds similar to yaacovCR#44 (comment) |
The flow now should be that it copies the default value when field not specified and should only be null if the default is null. If you could submit a reproduction or a failing test that would be helpful. |
Possibly we need to check for undefined here: https://github.com/ardatan/graphql-tools/blob/master/src/delegate/transforms/AddArgumentsAsVariables.ts#L158 |
With the difference possibly that in v5 the serialization between source and target schema may be converting undefined to null |
But I'm not convinced. Would that be a safe change? Can a non optional argument serialize to undefined, and then get dropped when stitching? Lets see some code to better understand the issue. |
Thanks for getting back to me @yaacovCR. Here's a minimal reproduction. Just run the test suite and you should see the problem. The first test which uses https://github.com/pcorey/graphql-tools-null-reproduction |
Thanks! Is the issue also apparent without the use of variables? |
@yaacovCR It looks like if I call |
Yes, thanks that was exactly my question and is very helpful. |
I think the undefined check should be with the original variables here: https://github.com/ardatan/graphql-tools/blob/master/src/delegate/createRequest.ts#L116 |
We should skip serialization if existing variable value is undefined. This check should probably go in both places, thought about it more, and seems quite unlikely that it should ever be the case that a non-optional argument is parsed internally to undefined. |
Also in FilterToSchema! |
See #1455 (comment) to test within alpha |
@yaacovCR I tried to test to alpha release, but it looks like something might be broken with the release? The reproduction repo fails because
And my real project fails to stitch in the remote schema completely due to a Your tests and changes look good to me, so this is probably user error. Any ideas what's up? |
Alpha gets ready for v6 and merging of graphql-toolkit and separation of Apollo link out of core functionality, mergeSchemas => stitchSchemas You can convert link to executor or subscriber using exported functions linkToExecutor and linkToSubscriber. I think an executor is the new name for what was a fetcher, with different option name in makeRemoteExecutableSchema to enable executions and mutations you just have to set an executor but to enable subscriptions you have to set a subscriber. In parallel to how upstream graphql-js has execute and subscribe for local schemas. |
@yaacovCR I see, thanks. Those changes fixed it. Both the reproduction and my actual project are working as expected. I really appreciate all your help! |
Thanks for filing this bug! |
I have noticed the same problem on the project I'm working. |
Closed by #1419. |
Hello @yaacovCR. I'm having the same issue when using v5.0.0. |
You are using really old version. We recommend you to migrate to the latest one. |
Hi,
I'm working with a local GraphQL schema that has a query (let's call it
search
) that accepts an optional enum argument,filter
:This schema is being stitched together with a remote schema using
mergeSchemas
.Using
graphql-tools@4.0.7
, when queryingsearch
without providing a value forfilter
,filter
wouldn't be provided as an argument to thesearch
resolvers, as I'd expect. Withgraphql-tools@5.0.0
, if I querysearch
withoutfilter
, thesearch
resolver will recieve{filter: null}
as its arguments. This is not what I'd expect, and is breaking some assumptions in my code thatfilter
will beundefined
, notnull
, if it's not provided by the client.If I don't use
mergeSchemas
, and just use the local schema directly, the code works as I'd expect.filter
isn't passed as an argument to thesearch
resolver. This leads me to believe that this is an issue withmergeSchemas
and/or schema stitching in general.@yaacovCR, do you have any ideas about this? I hate to tag you out of the blue, but the changelog mentioned that you did lots of work with schema stitching in
5.0.0
.Thanks!
The text was updated successfully, but these errors were encountered: