Giter VIP home page Giter VIP logo

Comments (7)

birkir avatar birkir commented on June 3, 2024 1

Thats to give you more control, so you can do something very very simple like this:

export default function Home(props) {

  const [data, setData] = React.useState(props.data.prismic);

  const handleClick = () => props.prismic.load({ ... })
    .then(setData);

  return ( ... );
}

from gatsby-source-prismic-graphql.

birkir avatar birkir commented on June 3, 2024

That's a good question. If I don't do the merge, we will loose all other data that's unrelated to this plugin.

I could try to merge everything but the result and then replace the result. Does that make sense?

from gatsby-source-prismic-graphql.

ffdead avatar ffdead commented on June 3, 2024

I think that makes sense. Could we try that?

I also wonder if this would impact paginating multiple cursors, I guess that should work?

from gatsby-source-prismic-graphql.

birkir avatar birkir commented on June 3, 2024

Can you try the 3.0.0 version of the plugin

from gatsby-source-prismic-graphql.

ffdead avatar ffdead commented on June 3, 2024

Unable to test on 3.0.0-alpha.14.

Seems like the load() function is no longer adding my after variable to the query so next page is never fetched.

Code used to trigger request:

prismic.load({ after: pageInfo.endCursor, first: pageSize })

Resulting query request:
´´´
https://antlerco.prismic.io/graphql?query=query%20NewsPageQuery(%24filter%3A%20Boolean!%20%3D%20false%2C%20%24industryFilter%3A%20String%2C%20%24first%3A%20Int%20%3D%2020%2C%20%24after%3A%20String)%20%7B%0A%20%20allFilters%3A%20allIndustry_tags%20%7B%0A%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20__typename%0A%20%20%7D%0A%20%20allAdvisors(first%3A%20%24first%2C%20after%3A%20%24after)%20%40skip(if%3A%20%24filter)%20%7B%0A%20%20%20%20totalCount%0A%20%20%20%20pageInfo%20%7B%0A%20%20%20%20%20%20startCursor%0A%20%20%20%20%20%20endCursor%0A%20%20%20%20%20%20hasPreviousPage%0A%20%20%20%20%20%20hasNextPage%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20__typename%0A%20%20%7D%0A%20%20filteredAdvisors%3A%20allAdvisors(first%3A%20%24first%2C%20after%3A%20%24after%2C%20where%3A%20%7Bindustry%3A%20%24industryFilter%7D)%20%40include(if%3A%20%24filter)%20%7B%0A%20%20%20%20totalCount%0A%20%20%20%20pageInfo%20%7B%0A%20%20%20%20%20%20startCursor%0A%20%20%20%20%20%20endCursor%0A%20%20%20%20%20%20hasPreviousPage%0A%20%20%20%20%20%20hasNextPage%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20_meta%20%7B%0A%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20__typename%0A%20%20%7D%0A%7D%0A&operationName=NewsPageQuery&variables=%7B%22filter%22%3Afalse%2C%22first%22%3A20%7D
´´´

from gatsby-source-prismic-graphql.

birkir avatar birkir commented on June 3, 2024

The load now takes a variables property.

So try: prismic.load({ variables: { after: pageInfo.endCursor, first: pageSize } })

from gatsby-source-prismic-graphql.

ffdead avatar ffdead commented on June 3, 2024

Great, using variables will pass it properly to the GraphQL query. I can see the proper request being made, and the new page data coming back in the Prismic response.

However, the page data prop never updates with the response. So the new data doesn't render.

from gatsby-source-prismic-graphql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.