-
Notifications
You must be signed in to change notification settings - Fork 2k
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
error in typeMapReducer causes graphql to fail on certain schemas #2439
Comments
...reflected a little more on what seems to be intended by typeMapReducer's check, so updated the issue statement, if you read early by email. |
@narration-sd Yes, you absolutely correct it's intentional. |
Ivan, thanks indeed for coming back so quickly. I checked for duplicating packages; So, I dumped out more of what
So, I think the problem actually has to be on the Gridsome side, and perhaps specifically in some operations that are done in its connector to over-the-wire GraphQL servers. They're from a standardd library, but maybe there's something about how the calls are being applied that's allowing the doubling up. A clue for that is maybe finding the duplicate types near the end of agr.introspect.json; we'll have to see. If you have any ideas, most welcome of course.
Again, much appreciation for your clear, immediate, and helpful response, Ivan. Best, |
@narration-sd If you can modify source code of
and print |
Thanks - that output's quite useful. Hadn't realized a stack trace could be had so easily... A good weekend to you, spasibo |
@IvanGoncharov , this is all sorted now, and reported for a close, over at the Gridsome issue. It turns out I had an extra source added, in some well-hidden outdated configuration for an early, superseded plugin someone once built for them. This managed to merge the same remote schema, accurately, but without the prefixing, thus your preflight was quite correct in picking off the problem. The stack traces were essential, in getting orders right, and thus arriving at this. |
how did you figure it out? |
This error exists in both 14.x and 15.x branches, and has a one-line tested fix, so presenting that here rather than in multiple pull requests.
Issue:
In either branch latest, graphql fails immediately for certain schemas, reporting:
Error: Schema must contain uniquely named types but contains multiple types named "Name"
where for my schema Name may be PageInfo or Mutation.
Others have reported similar problems, also for graphql as used in Gridsome.
Response:
Tracking this down via the stack trace and logging, the problem is that
function typeMapReducer()
in type/schema.js is doing a compare of objects for the Type name, to determine failure.Adding a cast to String before comparing solves this. The code becomes:
This code appears at apparent lines 338 in type/schema.js source for 14.x, and 319 in 15.x source, as these appear on this github repo.
It seems both branches should be repaired with fresh release, especially14.x, as many are using that in the field. Thanks.
Rationale:
The commonality for the PageInfo and Mutation terms that fail with present code is that they appear in multiple graphql Connections.
It's possible that the uniqueness test really does intend to compare objects, but that the situation is complicated by the fact that in Gridsome (also potentially in Gatsby, perhaps others), there are data-source-resolving prefixes added to the actual declaration of some terms, which arrive early in the
map
array fortypeMapReducer()
.I'm attaching a log of that
map
array, as in use at the point where the failure occurs. so you can see the use of prefixes.If the prefixes are the problem, then this 'fix' becomes a workaround, until a proper design can accomodate.
map.zip
The text was updated successfully, but these errors were encountered: