-
Notifications
You must be signed in to change notification settings - Fork 53
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
Repeated fragment in auto-generated query. #270
Comments
Ah interesting! How would that work in JS? |
I'm an OCaml dev, so I'm not sure I can answer that. But what I did to debug the problem (because I didn't understand why GitHub was answering with an empty
Then I tested the auto-generated query in GitHub's GraphQL explorer: query GetMilestoneMergedPullRequests($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
milestone(number: $number) {
pullRequests(first: 100, states: [MERGED]) {
nodes {
...PullRequestWithMilestoneAndCards
}
}
}
}
}
fragment PullRequestWithMilestoneAndCards on PullRequest {
id
databaseId
number
milestone {
...Milestone
}
projectCards(first: 20) {
...ProjectCards
}
}
fragment Milestone on Milestone {
id
number
title
description
}
fragment ProjectCards on ProjectCardConnection {
nodes {
id
column {
...Column
}
project {
...Project
}
}
}
fragment Column on ProjectColumn {
id
databaseId
}
fragment Project on Project {
columns(first: 50) {
nodes {
...Column
}
}
}
fragment Column on ProjectColumn {
id
databaseId
} and it highlighted the first |
Another simpler (and complete) example where it triggered this issue: fragment Milestone on Milestone {
id
}
fragment PullRequest on PullRequest {
id
milestone { ... Milestone }
}
query issueMilestone($owner: String!, $repo: String!, $number: Int!) {
repository(owner:$owner, name:$repo) {
issue(number:$number) {
id
milestone { ... Milestone }
timelineItems(itemTypes:[CLOSED_EVENT],last:1) {
nodes {
... on ClosedEvent {
closer {
... on PullRequest { ... PullRequest }
... on Commit {
associatedPullRequests(first: 2) {
nodes { ... PullRequest }
}
}
}
}
}
}
}
}
} |
I think some production users haven't hit this issue because they use the template tag option (default for rescript-apollo-client). What client are you using? I think this should be fixed regardless btw. |
I am calling graphql-ppx directly (I am not aware of any available client for native OCaml). |
This issue didn't happen with lower versions? (because handling of this shouldn't have changed too much I think) |
Before upgrading to 1.2.0, I didn't use fragments as much because the object encoding didn't make them as essential. So I don't think it's a regression but rather that I had never had an occasion of encountering this issue before. |
Interesting. I think JS GraphQL clients might do some deduplication. Need to look into this a little deeper. |
Hey @jfrolich, do you think this issue is reasonably easy to fix? I tried to look at the code to see if I could help, but I don't understand the code enough to manage to do that. |
BTW, you were right that (at least some) JS GraphQL clients do some deduplication: apollographql/graphql-tag#27 |
I encountered the same issue while trying to implement a data-layer using GraphQL PPX. It generated a duplicate fragment, which yields in server error. |
I've written a GraphQL request which uses several times the same fragment through different fragments (see the code below and https://github.com/coq/bot/blob/bc65314888df8e8c6c8bad55624f9492a36a1e78/bot-components/GitHub_GraphQL.ml#L30-L47 for the full context).
The auto-generated query contains two copies of the
Column
fragment, this makes the GraphQL query ill-formed.This is all the more annoying that, in this case, GitHub's GraphQL API doesn't answer with a clear error message but with:
(separately reported to GitHub)
The text was updated successfully, but these errors were encountered: