-
-
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
enums are broken after transformSchema #1056
Comments
I think the main issue here stems from your override. The GraphQL spec appears to claim that enums are meant to be what you said they were, and not to have custom resolvers. https://graphql.github.io/graphql-spec/draft/#sec-Enums My guess would be that a bug in graphql-js / graphql-tools is what allowed this to work for you at all in the first place. I'm not a contributor on this project... was hunting for something else in issues and stumbled across your post which made me curious. I know the above info is not super helpful, but my suggestion would be to not have custom resolvers for enums. Enums should return the value shown in the schema. |
@pthrasher Defining custom resolvers for enum values is absolutely supported by Apollo, according to its documentation. Whether they should do this or not as per spec, is another discussion altogether. Regardless, the fact remains that |
@nfantone, I am having trouble reproducing this with direct execution via graphql. Are you able to share a repo that reproduces this error? |
Same issue (using |
@633kh4ck We ended up not using schema transformations at all. As it turned out, for our use case (filtering some queries/mutations), |
Can you share a more complete code example? Would love to work on fixing this if I could reproduce it. Looks like this area is covered in test suite... |
@yaacovCR Good to read there's movement over here! Unfortunately, I opened this over 5 months ago and I'm no longer trying to use However, I remember that reproducing the problem was as simple as setting up a schema as was described in the original issue:
Maybe the problem was fixed already during this time? Also, I'm not entirely sure what that unit test you linked is trying to evaluate, but the resulting enum definitions from both schemas are most definitely not the same, as demonstrated in my analysis some months ago. A deep equality comparison should fail. In my use case, I'm not explicitly using |
The unit test is comparing the original result with the merged result. The resolvers in the merged schema are wrapped, but (a) the tests don't crash and (b) the results are the same, so the different resolvers are supposedly working correctly. I think this issue may have been fixed, but I could feel differently very soon if I saw a more fleshed out recent reproduction. I tried from the original issue and it looked ok to me. :) In general, not sure whether there is movement here... I opened up graphql-tools-fork to merge my own PRs and I am working on fixing what I can there. |
I was able to reproduce -- it had been fixed in root fields returning enum, but not nested fields. This should be fixed now in graphql-tools-fork v5.2.0. Let me know! (As always, I will try to separate this out to PR for upstream graphql-tools, but this may be difficult for this fix, as relies on my refactoring from other fixes.) |
I am not great at predicting the future, but I don't see this getting merged to upstream graphql-tools any time soon. In general, I would love to hear from the package maintainers... It has been radio silence from them re: pull requests and issues for some time, hence the fork. I would love to just bring everything back in, it's just so far a handful of (important?) bug fixes and a few new transformers. |
I can confirm that graphql-tools-fork fixes this issue I had with mergeSchemas |
We recently released an alpha version of GraphQL Tools (#1308) that should fix the issue. Please update
Let us know if it solves the problem, we're counting for your feedback! :) |
Rolled into #1306 |
I have a simple schema defining an
enum
and a custom resolver for it.This works fine in queries/mutations if I use the schema returned by
makeExecutableSchema
, but doesn't if using the schema returned bytransformSchema
. Queries that would return aPersonType
all end up with the following error:If you don't ask for this particular field in your response, everything works just fine.
I'm using
transformSchema
to filter out some fields - but found out that even if I don't pass in any transformations (which I'd expect to return an exact copy of the given schema), the error is still there. Basically:This happens for every other
enum
in my schema. So there's evidently some difference between the originalschema
and the returned value fromtransformSchema
. Schema introspection reveals the enum values correctly for both cases, however. And, after debugging, I can confirm that the definition forPersonType
is present in both of them.Moreover, here are the
resolve
functions for thepassengerType
field (theenum
on the query output): original schema (targetSchema
) vs. transformed schema (schema
).You can see that they are most definitely not the same, starting from its
name
("defaultMergedResolver"
).Any advice on this?
The text was updated successfully, but these errors were encountered: