Skip to content
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

Relay constructing wrong query when querying for missing fields on a connection #305

Closed
KyleAMathews opened this issue Sep 14, 2015 · 4 comments
Assignees

Comments

@KyleAMathews
Copy link
Contributor

I have one component with this query fragment:

    viewer: () => Relay.QL`
      fragment on User {
        id
        allPosts(first: 5) {
          edges {
            node {
              title
            }
          }
        }
      }
    `

If I click from that component to another one that has the same query except it also asks for the body field e.g.:

    viewer: () => Relay.QL`
      fragment on User {
        id
        allPosts(first: 5) {
          edges {
            node {
              title
              body
            }
          }
        }
      }
    `

Relay then sends in parallel 5 queries that look like:
{ query: 'query Router{node(id:"UG9zdDo1MA=="){body,id}}

This errors as the Node type doesn't have a body field.

@josephsavona josephsavona self-assigned this Sep 14, 2015
@josephsavona
Copy link
Contributor

Thanks for reporting this. It looks like diffRelayQuery() isn't taking into account the parent type.

josephsavona added a commit that referenced this issue Sep 15, 2015
Summary: Addresses the issue in #305: `diffRelayQuery` creates top-level queries for missing information but did not wrap the fields in fragments based on type. Rather than use `refragmentRelayQuery` which requires a full traversal of the query, this change relies on the fact that input queries are already correctly fragmented, and only needs to group the top-level fields into fragments by type.

The schema changes are required because otherwise `... on FeedUnit` would not be allowed in a `Node` context.
Closes #316

Reviewed By: @wincent

Differential Revision: D2442000
@josephsavona
Copy link
Contributor

@KyleAMathews thanks again for reporting this - the issue is now fixed on master, i'm going to close.

@KyleAMathews
Copy link
Contributor Author

Thanks for the fix! Also great talk yesterday @scale. Watched it this
morning.
On Tue, Sep 15, 2015 at 2:26 PM Joseph Savona notifications@github.com
wrote:

Closed #305 #305.


Reply to this email directly or view it on GitHub
#305 (comment).

@josephsavona
Copy link
Contributor

thanks! :-)

josephsavona added a commit that referenced this issue Sep 18, 2015
Summary: Addresses the issue in #305: `diffRelayQuery` creates top-level queries for missing information but did not wrap the fields in fragments based on type. Rather than use `refragmentRelayQuery` which requires a full traversal of the query, this change relies on the fact that input queries are already correctly fragmented, and only needs to group the top-level fields into fragments by type.

The schema changes are required because otherwise `... on FeedUnit` would not be allowed in a `Node` context.
Closes #316

Reviewed By: @wincent

Differential Revision: D2442000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants