reactjs – Can’t normalize response graphQl (ApolloClient)
I would to normalize GET_NATIONS_LIST response query.
I’m using React and GraphQl with the client Apollo.
My query GET_NATIONS_LIST:
export const GET_NATIONS_LIST = gql(`
query getNationsList{
nationsList{
acronyms
description
}
}
`)
My graphQl configuration:
export const GRAPHQL_CLIENT_CONFIG = {
link: from([errorLink, new HttpLink({uri: '/graphql'})]),
cache: new InMemoryCache({
typePolicies: {
Query: {
fields: {
nationsList:(existing, options)=>{
console.log("existing",existing) //it print the right response
return existing?.map(nation=> ({
label: nation?.acronyms,
value: nation?.description
})
}
}
}
}
})
}
The console log “existing” print the right response but the return don’t update cache.
How can I normalize query response ?
Read more here: Source link
