Tag: apollo-client
-
Unknown Custom Scalars during Apollo Client GraphQL 3.0 migration
0 I have been following this link to do an apollo client version upgrade: https://www.apollographql.com/docs/kotlin/migration/3.0/ After completing the section to replace customTypeMapping I am now seeing the following error: Apollo: unknown custom scalar(s) in customScalarsMapping: Date,Currency,Year,Month,Percentage,MediaType,Base64 My build.gradle.kts file has been updated to contain the updated custom scalar mapping methods: mapScalar("Date", "java.time.LocalDate") mapScalar("Currency", "java.util.Currency") mapScalar("Year",…
-
Apollo-Server subscription to Postgres database
1 I have a postgres table (User) which is fed data from a third party service like Airflow or Nifi. I am running an apollo-server with NodeJS which fetches the user data and passes this data to the React component. One way to show the details of users is using polling in apollo-client which will…
-
`Cannot use e “__Schema” from another module or realm.` and `Duplicate “graphql” modules` using ApolloClient
5 I have a React application with ApolloClient with Apollo-Link-Schema. The application works fine locally but in our staging environment (using GOCD), we get the following error: Uncaught Error: Cannot use e “__Schema” from another module or realm. Ensure that there is only one instance of “graphql” in the node_modules directory. If different versions of…
-
How to make a query in Apollo Client properly?
0 I’m new to Apollo Client and I want to test API endpoint to fetch the data. const client = new ApolloClient({ cache: new InMemoryCache(), link: new HttpLink({ uri: "https://api.thecatapi.com/v1/breeds", useGETForQueries: true }), }); client .query({ query: gql` { id name } `, }) .then((result) => console.log(result)) In data field I keep getting undefined. I…
-
Graphql in apollo client: local data is not normalized
0 I want to normalize (i.e. flatten nested elements) my graphql’s local cache for efficiency reasons (otherwise a change in a nested item would redraw all components). My understanding was that Apollo would automatically normalize the cache… but apparently it seems like I misunderstood. Indeed, if I do: const IS_LOGGED_IN = gql` query IsUserLoggedIn {…
-
Error encountered while automatically updating the cache when creating a CompanyQuote component
0 I’m working on a project where I’ve created a backend script to handle GraphQL requests. I have a file called company.graphql that contains a query to retrieve information about a company and its related quotes. Here’s a snippet of the script query Companie($id: String!) { companie(id: $id) { attachmentId companieQuotes { attachmentId } }…
-
Apollo client: how to create client-side mutations
0 TL;DR: In Apollo client, how can I create client mutations usable with useMutation now that local resolvers are removed? (useful for debug, abstraction, reusability…) Long version: I’m learning how to use Apollo client to deal with a local nested state. For now, I’m using something like: client.writeQuery({ query: IS_LOGGED_IN, data: { isLoggedIn: false, },…
-
How can I cache nested objects with Apollo Client?
3 I’m using the Contentful GraphQL API to fetch a collection of items, in this example football clubs. query Clubs($limit: Int!, $skip: Int!) { clubCollection(limit: $limit, skip: $skip) { total items { name description } } } The structure of the response is: clubCollection: { items: [{ … array of all the clubs }] }…
-
Apollo Client: switch between local and remote server
0 Currently I’m creating an http link with a relative URI. This works when the server is running locally, and also works when the client and server are hosted remotely: const httpLink = createHttpLink({ uri: ‘/.netlify/functions/foo’, }); const authLink = setContext((_, { headers }) => { const token = process.env.REACT_APP_TOKEN return { headers: { …headers,…
-
Why apollo client removes some properties (sets them to null) from a cached object spontaneously?
0 I’m using @apollo/client version 3.7.3 in a react.js, typescript application. After fetching a list of objects from the server, some values are removed from the cache spontaneously! So when the client gets the data from the server, it stores them in the cache to be used in the UI and the cache version is…