GithubHelp home page GithubHelp logo

Comments (5)

jeffutter avatar jeffutter commented on May 22, 2024

Any thoughts on this? Anyone else run into this problem?

from reason-apollo.

Gregoirevda avatar Gregoirevda commented on May 22, 2024

@jeffutter this should be added to the bindings!

fetchMore({
            variables: {
              offset: data.feed.length
            },
            updateQuery: (prev, { fetchMoreResult }) => {
              if (!fetchMoreResult) return prev;
              return Object.assign({}, prev, {
                feed: [...prev.feed, ...fetchMoreResult.feed]
              });
            }
          })

We currently have this:

fetchMore: (~variables) =>
      apolloData##fetchMore({
          "variables": variables,
          "query": graphqlQueryAST,
}),

But should have:

fetchMore: (~variables, ~updateQuery: updateQuery) =>
      apolloData##fetchMore({
          "variables": variables,
          "query": graphqlQueryAST,
          "updateQuery": updateQuery
 }),

With updateQuery type definition that needs to be defined at the beginning of the module :

type updateQuery = (~previousResult: renderPropObj, ~nextResult: renderPropObj) => Js.t;

Not sure if previousResult === renderPropObj, but just data, loading, error (in that case those 3 types should be extracted from the type) Same for fetchMoreResult.

from reason-apollo.

jeffutter avatar jeffutter commented on May 22, 2024

@Gregoirevda Thanks for the direction. I think I have this somewhat implemented over at: #99

However, I'm running into an error:

index.js:2178 TypeError: mapFn is not a function
    at ObservableQuery.js:328
    at tryFunctionOrLogError (errorHandling.js:3)
    at ObservableQuery.updateQuery (ObservableQuery.js:327)

It's coming from apollo-client. I think I'm not passing the correct thing as the function sometimes, but I don't see how that could be happening. Do you see anything obviously wrong over there?

from reason-apollo.

studious avatar studious commented on May 22, 2024

I'm keenly following this one because I am hopeful the work here will make a binding easier to implement on the Query component for subscribeToMore which works in a similar manner. It takes document a gql template string like query in fetchMore and the updateQuery function and returns an unsubscribe function.

https://www.apollographql.com/docs/react/api/react-apollo.html#graphql-query-data-subscribeToMore

from reason-apollo.

Gregoirevda avatar Gregoirevda commented on May 22, 2024

subscribeToMore is already implemented here: https://github.com/apollographql/reason-apollo/blob/feature/Query-subscribeToMore/src/graphql-types/ReasonApolloQuery.re#L37.
I need to merge everything together.
You can already use it under reason-apollo@alpha :)

I also have a full example of it's usage that will be merged soon

from reason-apollo.

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.