Skip to content

What is currently the best way to use Apollo GraphQL with the ORM? #1013

Answered by CodeDredd
rbartholomay asked this question in Q&A
Discussion options

You must be logged in to vote

Hey :),

the best way to use any api with pinia-orm is to use the repository. I am still working on the examples and cookbook so that such questions are clear.
So normally you would have a UserModel and UserRepository. In the repository you then initilize through the construct the api client.

Ihaven't tested the code below, but thats how i would do it now. So you have something like this:

import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client/core'

// Create the apollo client
export const useApolloClient = () => { 

const httpLink = createHttpLink({
  // You should use an absolute URL here
  uri: 'http://localhost:3020/graphql',
})

// Cache implementation
const cache = 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by CodeDredd
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants