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

fix: Add list of node types as X-GraphQL-Keys instead of list of edge types #2590

Conversation

jasonbahl
Copy link
Collaborator

@jasonbahl jasonbahl commented Oct 21, 2022

What does this implement/fix? Explain your changes.

This update visitor in the QueryAnalyzer to find the "node" type that's being queried in a list and add it to the keys instead of adding the "edge" type.

Does this close any currently open issues?

closes #2589

Any relevant logs, error output, GraphiQL screenshots, etc?

Before (Posts.edges):

The following query:

{
  posts(first:5) { 
    edges { 
      node { 
        id
        title
      }
    }
  }
}

Would produce the following X-GraphQL-Keys:

b682e8e049ae0f0a6c6c65d66a42af48 graphql:Query 
list:rootquerytopostconnectionedge cG9zdDoxMTY3 
cG9zdDoxMTM1 cG9zdDoxMTIw cG9zdDoxMTA5 cG9zdDoxMDk3

After (Posts.edges):

The same query produces the following X-GraphQL-Keys:

b682e8e049ae0f0a6c6c65d66a42af48 graphql:Query list:post 
cG9zdDoxMTY3 cG9zdDoxMTM1 cG9zdDoxMTIw 
cG9zdDoxMTA5 cG9zdDoxMDk3

Before: (ContentNodes.edges)

The following query:

{
  contentNodes(first:5) { 
    edges { 
      node { 
        id
        ...on NodeWithTitle {
          title
        }
      }
    }
  }
}

Would produce the following X-GraphQL-Keys:

4c854ebb7a8311233d939e1f7c01c37d graphql:Query 
list:rootquerytocontentnodeconnectionedge cG9zdDoxMjM3 
cG9zdDoxMTY3 cG9zdDoxMTM1

After (ContentNodes.edges):

The same query produces the following X-GraphQL-Keys:

4c854ebb7a8311233d939e1f7c01c37d graphql:Query 
list:contentnode list:mediaitem list:page list:post list:graphqldocument 
cG9zdDoxMjM3 cG9zdDoxMTY3 cG9zdDoxMTM1

@jasonbahl jasonbahl added the Needs: Tests Tests should be added to ensure this works as expected label Oct 21, 2022
@jasonbahl jasonbahl self-assigned this Oct 21, 2022
@jasonbahl jasonbahl changed the title Add list of node types as X-GraphQL-Keys instead of list of edge types fix: Add list of node types as X-GraphQL-Keys instead of list of edge types Oct 21, 2022
@coveralls
Copy link

coveralls commented Oct 21, 2022

Coverage Status

Coverage increased (+0.004%) to 82.182% when pulling 3fb9022 on jasonbahl:bug/#2589-keys-tracks-list-of-edges-vs-list-of-nodes into 34f9c76 on wp-graphql:develop.

@codeclimate
Copy link

codeclimate bot commented Oct 21, 2022

Code Climate has analyzed commit 3fb9022 and detected 0 issues on this pull request.

View more on Code Climate.

@jasonbahl jasonbahl merged commit fffa851 into wp-graphql:develop Oct 24, 2022
@jasonbahl jasonbahl mentioned this pull request Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Tests Tests should be added to ensure this works as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QueryAnalyzer tracks list of edges, instead of nodes
3 participants