Git Product home page Git Product logo

Comments (4)

lfades avatar lfades commented on July 18, 2024

Right, you may want to do this:

withApollo({
  client: ({ link }) => ({
    link: link as ApolloLink,
    cache: new InMemoryCache()
  }),
  link: {
    http: new HttpLink({
      uri: GRAPHQL_URL
    })
  }
})

Two things to notice:

First that I'm adding link, I'm already doing that by default but ApolloClientOptions requires link to be present, I don't know what to do there actually, I don't want to clone ApolloClientOptions but I want to use it, so it gives proper type checking.

Second that I'm using link as ApolloLink, that's because of this: { headers?: IncomingHttpHeaders; link?: ApolloLink }, link? is undefined when you're returning an ApolloClient directly and not using the custom link (the one that has http, ws, setContext), but in this case it's always defined.

If you know how can I improve the types, specially for the second part, it would be awesome 👍

from next-with-apollo.

lfades avatar lfades commented on July 18, 2024

I created a new branch v2.2 that fixes this issues by accepting an ApolloClient directly into withApollo or a function that returns an ApolloClient or (this case) an object that uses client and link to build the ApolloClient, it's backwards compatible unless you're using typescript, let me know what you think, and if it should be a 3.0 instead

from next-with-apollo.

SpaceK33z avatar SpaceK33z commented on July 18, 2024

Thanks so much! Yeah I guess this would be a v3 since it is breaking?

from next-with-apollo.

lfades avatar lfades commented on July 18, 2024

Yes, I'm having a discussion about 3.0 with myself here, feel free to join, I would like a second opinion

from next-with-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.