apollo-client

GraphQL dynamic query building

人盡茶涼 提交于 2019-12-05 00:44:23
I have a GraphQL server which is able to serve timeseries data for a specified source (for example, sensor data). An example query to fetch the data for a sensor might be: query fetchData { timeseriesData(sourceId: "source1") { data { time value } } } In my frontend, I want to allow the user to select 1 or more sources and show a chart with a line for each one. It seems like this would be possible by using a query like this: query fetchData { series1: timeseriesData(sourceId: "source1") { data { time value } } series2: timeseriesData(sourceId: "source2") { data { time value } } } Most GraphQL

Apollo-client (react) - Update on create mutation - “Can't find field Fund({}) on object (ROOT_QUERY)”

一世执手 提交于 2019-12-04 18:09:11
问题 Using: "react-apollo": "^1.4.3" In the parent component I query using GraphQL a parent node 'Fund' with children 'fundQuarterlyMetric'. This returns data in the following format: { id name ... fundQuarterlyMetrics (orderBy: asAtDate_ASC) { id year quarter ... } } When I try to create a new fundQuarterlyMetrics I have to update the local store on react-apollo using the update feature (Apollo Client docs). It gives me an error: Can't find field Fund({}) on object (ROOT_QUERY) { "Fund({\"id\":\

Apollo Client: Variable is not defined. Received status code 400

二次信任 提交于 2019-12-04 03:56:02
问题 I'm trying to use dynamic variable in a GraphQL query using Apollo Client. I have followed the documentation, but Apollo keeps giving me errors, saying that my variables are not defined, and ultimately responding with status code 400. Here is what the documentation for Apollo said: mutate: (options?: MutationOptions) => Promise A function to trigger a mutation from your UI. You can optionally pass variables, optimisticResponse, refetchQueries, and update in as options, which will override any

How to configure Graphene-Django to work with persisted queries?

狂风中的少年 提交于 2019-12-03 18:22:20
It looks like my company is going to move forward with Persisted Queries from the Apollo Client, as is discussed here: https://dev-blog.apollodata.com/persisted-graphql-queries-with-apollo-client-119fd7e6bba5 In this article there is mention that something needs to be done to the Middleware on the server. I have been unable to find any information as to what needs to be changed with Graphene-Django. Can anyone provide any advice? Robert Persisted queries are not a part of the GraphQL spec and, as such, can be implemented in a wide variety of ways. Here are a few examples of how you might want

Apollo Server - Confusion about cache/datasource options

房东的猫 提交于 2019-12-03 16:43:33
The docs ( https://www.apollographql.com/docs/apollo-server/features/data-sources.html#Using-Memcached-Redis-as-a-cache-storage-backend ) show code like this: const { RedisCache } = require('apollo-server-cache-redis'); const server = new ApolloServer({ typeDefs, resolvers, cache: new RedisCache({ host: 'redis-server', // Options are passed through to the Redis client }), dataSources: () => ({ moviesAPI: new MoviesAPI(), }), }); I was wondering how that cache key is used, considering it seems like the caching is actually custom implemented in something like MoviesAPI() and then used via

Invalid Auth Token with Rails, Graphql, Apollo Client

好久不见. 提交于 2019-12-03 08:03:38
I am trying to get a basic Rails, Graphql, Apollo-Client setup working but having trouble with 422 errors 'invalid auth token' on the rails side. Does my use of apollo look wrong? It is a Rails 5 app with graphql gem and apollo client. const csrfToken = document.getElementsByName('csrf-token')[0].content const client = new ApolloClient({ networkInterface: createNetworkInterface({ uri: '/graphql', credentials: 'same-origin', headers: { 'X-CSRF-Token': csrfToken } }), }); client.query({ query: gql` query Camillo2 { user { id email created_at } } `, }) .then(data => console.log(data)) .catch

Apollo GraphQl Storing derived data

好久不见. 提交于 2019-12-02 14:59:44
问题 Some context : I'm developing a React JS app that reads geographic points out of a database and graphs/maps them in various ways. There are raw maps and plots that just show data straight from the database but there are also plots and metrics that involve analysis on the points like slope plot, area under graph, histograms, Euclidean distance etc. I have a GraphQL client set up to feed me data to my react app with Apollo-Client installed. Here's a sample of the GraphQL response: { "data": {

Apollo GraphQl Storing derived data

六眼飞鱼酱① 提交于 2019-12-02 05:38:34
Some context : I'm developing a React JS app that reads geographic points out of a database and graphs/maps them in various ways. There are raw maps and plots that just show data straight from the database but there are also plots and metrics that involve analysis on the points like slope plot, area under graph, histograms, Euclidean distance etc. I have a GraphQL client set up to feed me data to my react app with Apollo-Client installed. Here's a sample of the GraphQL response: { "data": { "Points": [ { "pid": 13196, "x": 251.88491821289062, "y": 374.1650085449219 }, { "pid": 13197, "x": 257

Apollo Client: Variable is not defined. Received status code 400

試著忘記壹切 提交于 2019-12-01 18:36:17
I'm trying to use dynamic variable in a GraphQL query using Apollo Client. I have followed the documentation, but Apollo keeps giving me errors, saying that my variables are not defined, and ultimately responding with status code 400. Here is what the documentation for Apollo said: mutate: (options?: MutationOptions) => Promise A function to trigger a mutation from your UI. You can optionally pass variables, optimisticResponse, refetchQueries, and update in as options, which will override any props passed to the Mutation component. The function returns a promise that fulfills with your

Use result for first query in second query with Apollo Client?

耗尽温柔 提交于 2019-12-01 08:27:33
Im using Apollo, React and Graphcool. I have a query to get the logged in users ID: const LoginServerQuery = gql` query LoginServerQuery { loggedInUser { id } } `; I need to use the returned ID in another query which is called from the same React component. Here Ive hardcoded "xxxxxxxxxxxxx" which is where the dynamic user ID needs to go: const LocationQuery = gql` query LocationsQuery { User(id: "xxxxxxxxxxxxx") { location { name } } } `; If you import compose like so: import { graphql, compose } from 'react-apollo'; Then you can pass the props to the second query with this: const