Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

apollo client multiple endpoints

//Declare your endpoints
const endpoint1 = new HttpLink({
    uri: 'https://api.hashnode.com/graphql',
    ...
})
const endpoint2 = new HttpLink({
    uri: 'endpoint2/graphql',
    ...
})

//pass them to apollo-client config
const client = new ApolloClient({
    link: ApolloLink.split(
        operation => operation.getContext().clientName === 'endpoint2',
        endpoint2, //if above 
        endpoint1
    )
    ...
})

//pass client name in query/mutation
useQuery(QUERY, {variables, context: {clientName: 'endpoint2'}})
Comment

PREVIOUS NEXT
Code Example
Javascript :: Listen to custom event in Vue.js 
Javascript :: telerik grid destroy table 
Javascript :: convert array to conventional array js 
Javascript :: knex js how to group by many items 
Javascript :: what happens if pass argument to a function that does not have parameters javascript 
Javascript :: FirebaseError: Unknown field filter op. 
Javascript :: nuxtjs update parent parameter 
Javascript :: lwc reduceErrors showtoast 
Javascript :: regex mobile 
Javascript :: convert html table to pdf 
Javascript :: mobile version 
Javascript :: js notimplemented error 
Javascript :: does expo av support mp3 
Javascript :: declare multiple variable javascript 
Javascript :: convert string to moment date 
Javascript :: Fetch data from multiple pages of an API in react native 
Javascript :: shell curl path of json file as parameter without temporal file 
Javascript :: rest object javascript 
Javascript :: 3336tfsdfd 
Javascript :: generate html by javascript 
Javascript :: extract image in p5.js 
Javascript :: how to add another model into type of model in mongodb schema 
Javascript :: js 2 varibale points on same values 
Javascript :: how to hide javascript code from client 
Javascript :: AngularJS Graphs & Charts - Mix of solid & dotted 
Javascript :: angularjs Split date and time from api response 
Javascript :: Angular js set default tab with ng-repeat in array object 
Javascript :: Difficulties handling asynchronous taks using image-picker and copying files in react-native 
Javascript :: JSON.stringify on Arrays adding numeric keys for each array value 
Javascript :: parse json keep the order 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =