apollo-client

GraphQL Query Runs Sucessfully One Time and Fails To Run Again using Apollo and AWS AppSync

青春壹個敷衍的年華 提交于 2019-12-23 02:44:06
问题 I'm using the basic client configuration from the example on the first page of https://github.com/awslabs/aws-mobile-appsync-sdk-js repo: const client = new AWSAppSyncClient({ url: appSyncConfig.graphqlEndpoint, region: appSyncConfig.region, auth: { type: appSyncConfig.authenticationType, apiKey: appSyncConfig.apiKey, } }); But without the <Rehydrated> component, and with a Redux <Provider> component. The highest level parent component is wrapped like this: <Provider store={store}>

apollo-client does not work with CORS

心不动则不痛 提交于 2019-12-21 09:00:36
问题 I am writing a graphql server component on AWS Lambda (NOT using graphql-server). On the client side I'm using apollo-client. On the response of the lambda function I'm setting const response = { statusCode: 200, headers: { "Access-Control-Allow-Origin": "*" // Required for CORS support to work }, body: JSON.stringify({ result: 'mock data', input: event, }), }; callback(null, response); On the client side using ApolloClient I get the following error Response to preflight request doesn't pass

Apollo Server - Confusion about cache/datasource options

佐手、 提交于 2019-12-21 05:23:13
问题 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

Apollo Server - Confusion about cache/datasource options

筅森魡賤 提交于 2019-12-21 05:23:05
问题 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

Invalid Auth Token with Rails, Graphql, Apollo Client

瘦欲@ 提交于 2019-12-21 02:30:54
问题 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:

Strange issue with useQuery: Query arguments not being read

ε祈祈猫儿з 提交于 2019-12-19 17:47:16
问题 I have a component that passes a string ( userToFetch ) it as a variable parameter in a parameterized query. The component looks like this: // pages/index.jsx import React from 'react'; import { useQuery } from '@apollo/react-hooks'; import gql from 'graphql-tag'; const GET_USERS = gql` query users ($limit: Int!, $username: String!) { users (limit: $limit, where: { username: $username }) { username firstName } } `; const Home = () => { const userToFetch = 'jonsnow'; const { loading, error,

Strange issue with useQuery: Query arguments not being read

房东的猫 提交于 2019-12-19 17:46:03
问题 I have a component that passes a string ( userToFetch ) it as a variable parameter in a parameterized query. The component looks like this: // pages/index.jsx import React from 'react'; import { useQuery } from '@apollo/react-hooks'; import gql from 'graphql-tag'; const GET_USERS = gql` query users ($limit: Int!, $username: String!) { users (limit: $limit, where: { username: $username }) { username firstName } } `; const Home = () => { const userToFetch = 'jonsnow'; const { loading, error,

How to use client.query without JSX components in Apollo Client?

三世轮回 提交于 2019-12-18 08:54:08
问题 I'm trying to make a query in Apollo Client with React without returning a JSX component, just an object (the data object that is received when making a common query to Apollo Server). I tried using <Query /> component, but it returns me a React Node and I only need an object. The documentation only explain methods that return JSX components at some point, when all that I'm looking to do is send a request and process the response in a callback. Actually I'm trying this way (I'm using

Apollo GraphQL subscriptions is not working in Vuejs

烈酒焚心 提交于 2019-12-13 13:07:03
问题 I am using GraphQL Subscription with Prisma and vuejs + apollo client In local system, I am running vuejs at http://localhost:8080 and server at http://localhost:4000. I want to display recently added and updated records in dashboard. I have implemented subscription in my local system and it's working proper. I push all server side and client side code to server but subscription is not working there. I am using AWS server. Everything is working proper except subscription. I set up websockets

Apollo readQuery Fails Even Though Target Object is Present?

﹥>﹥吖頭↗ 提交于 2019-12-12 10:11:28
问题 I'm working on a call to readQuery. I'm getting an error message: modules.js?hash=2d0033b4773d9cb6f118946043f7a3d4385825fe:25847 Error: Can't find field resolutions({"id":"Resolution:DHSzPa8bvPCDjuAac"}) on object (ROOT_QUERY) { "resolutions": [ { "type": "id", "id": "Resolution:AepgCCio9KWGkwyMC", "generated": false }, { "type": "id", "id": "Resolution:DHSzPa8bvPCDjuAac", // <==ID I'M SEEKING "generated": false } ], "user": { "type": "id", "id": "User:WWv57KsvqWeAoBNHY", "generated": false }