• Resolved Vivek Kotadiya

    (@vivekkotadiya)


    Hello there,

    I installed WPGraphQL samrt cache plugin and using it’s persist query cache. I saved on uqery in graphQL documents. Here is my query:

    query getCategory($id: ID = "/article/test-article") {
    category(id: $id, idType: URI) {
    id
    uri
    description
    name
    termTaxonomyId
    }
    }

    This generates alias and I can use that query id with get request and it works fine.

    Here, I have question is if I have 1000 categories and I want get category data with get request by creating query with variables is it possible. I want something like below with with graphQl documents:

    query getCategory($id: ID = "") {
    category(id: $id, idType: URI) {
    id
    uri
    description
    name
    termTaxonomyId
    }
    }
    variables: "{
    "id": "/article/test-article"
    }"

    Here, “id” will be URI of the article user visit on front-end. So this can be achieve with graphQL documents for dynamic variables?

Viewing 1 replies (of 1 total)
  • Plugin Author Jason Bahl

    (@jasonbahl)

    @vivekkotadiya Yes, you can use the queryId along with variables.

    For example, I have the following query saved as a persisted query:

    query GetPosts($first:Int) {
    posts(first:$first) {
    pageInfo {
    startCursor
    endCursor
    hasNextPage
    hasPreviousPage
    }
    nodes {
    id
    title
    }
    }
    }

    And I can query this via a GET request and queryId and pass variables like so:

Viewing 1 replies (of 1 total)
  • The topic ‘Persist query for nodeByUri’ is closed to new replies.