apollo

Does the Apollo client cache nested objects in React?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 18:39:33
问题 Take the following queries: query Foo { foo { id bar(id: 1) { id baz } } } query Bar { bar(id: 1) { id baz } } Sometimes, running the 2nd query gets me a cached version of bar . Other times, it doesn't, but I'm not sure if this is because the query is run multiples times or because that's the default behaviour of the Apollo client in React. 回答1: No, it doesn't (as of Nov 2019, at least). To put the bar object in the cache when running the Foo query, you need to create the in-memory cache like

配置中心 Apollo 1.4 安装

若如初见. 提交于 2019-12-11 18:33:57
基础 Apollo服务端:1.8+ Apollo客户端:1.7+ 下载资源包 #https://github.com/ctripcorp/apollo/releases apollo-adminservice-1.4.0-github.zip apollo-configservice-1.4.0-github.zip apollo-portal-1.4.0-github.zip 数据库配置 create database apolloportaldb; GRANT ALL PRIVILEGES ON apolloportaldb.* TO 'apollo'@'%' identified by 'apollo'; create database apolloconfigdb; GRANT ALL PRIVILEGES ON apolloconfigdb.* TO 'apollo'@'%'; flush privileges; #下载资源 cd /tmp git clone https://github.com/ctripcorp/apollo.git #导入apolloportaldb mysql> use apolloportaldb; Database changed mysql> source /tmp/apollo/scripts/db/migration/portaldb

apollo集群部署

限于喜欢 提交于 2019-12-11 18:27:40
apollo集群部署 1. 准备工作 1.1. 服务器准备(配置根据情况调整) 准备好安装apollo的三台服务器 配置4CPU,4G内存,20GB硬盘 假设三台服务器IP为 172.16.10.208 172.16.10.209 172.16.10.210 修改相应hostname apollo-1 apollo-2 apollo-3 1.2. 安装jdk1.8 rpm -ivh jdk-8u231-linux-x64.rpm 在配置好后,可以通过如下命令检查: java -version 样例输出: java version "1.8.0_231" Java ( TM ) SE Runtime Environment ( build 1.8.0_231-b11 ) Java HotSpot ( TM ) 64-Bit Server VM ( build 25.231-b11, mixed mode ) 创建安装目录 mkdir -p /opt/server/apollo 3. 初始化MySQL数据 版本要求:5.6.5+ SHOW VARIABLES WHERE Variable_name = 'version' ; ±--------------±-----------+ | Variable_name | Value | ±--------------±----------

Schema from nested JSON list

与世无争的帅哥 提交于 2019-12-11 16:45:27
问题 I have a JSON list which captures one to many relationships. For example, School can have multiple Class objects and Class can have multiple Student objects, but Student only belongs to one Class and one School: { "School": [ { "id": 1, "name": "Grad School", "Class": [ { "name": 101, "Student": [ { "name": 501, "propertyA": "test" }] }] }] } I am trying to convert this JSON example into an appropriate schema but the nesting is causing issues. Apollo appears to be able to help but the example

Array of objects convert into object of objects when I use Apollo

两盒软妹~` 提交于 2019-12-11 16:40:09
问题 In our project we use Apollo client to send queries to GraphQL. Strangely it converts the variables into object of objects. let variables = [{myField: "myVal"}]; graphql.mutate("mutate myFunction($data:[MyInputType]){ myFunction(myArg: $data){...blabla...} }", variables); When I run the mutation and check request headers, I see that my variables are converted into object of objects. {"0": {"myField": "myVal"}} Does this method force variables to be object by default? Is it possible to send

I'm getting a 'Wrapped promise not iterable error' even though I have only one parameter

别等时光非礼了梦想. 提交于 2019-12-11 15:28:34
问题 I'm trying to use a Promise.all in my node.js microservice. The intent of the Promise.all is to go through all the elements in an array (of queries), and via apolloFetch, calls another microservice, which then executes those queries in a database and then returns back success or error. I'm getting a 'Wrapped promise is not iterable' error - I checked a few posts on SO that have similar errors but in all those cases there are 2 arguments being passed, whereas I'm passing just one - EXCEPT that

How to deploy Next.js with GraphQL backend on Zeit Now?

牧云@^-^@ 提交于 2019-12-11 11:47:03
问题 I have an Next.js/Express/Apollo GraphQL app running fine on localhost. I try to deploy it on Zeit Now, and the Next.js part works fine, but the GraphQL backend fails because /graphql route returns: 502: An error occurred with your deployment Code: NO_STATUS_CODE_FROM_LAMBDA My now.json looks like: { "version": 2, "builds": [ { "src": "next.config.js", "use": "@now/next" }, { "src": "server/server.js", "use": "@now/node" } ], "routes": [ { "src": "/api/(.*)", "dest": "server/server.js" }, {

Why do we need `cacheRedirects` at all?

给你一囗甜甜゛ 提交于 2019-12-11 08:15:05
问题 I read the docs on interacting with cached data and while I understand how cacheRedirects works, I'm a bit confused why it is needed in the first place. This is part of the reason why I asked this other question: Does the Apollo client cache nested objects in React? We know that the data is most likely already in the client cache, but because it's requested with a different query, Apollo Client doesn't know that. Why is that? Copy-pasting the example in the docs, for clarity: query ListView {

Apollo can't access queryVariables in update: after a mutation

独自空忆成欢 提交于 2019-12-11 07:36:14
问题 I am trying to use update: to update a query after performing a mutation. The problem is that the query in the store has several different variables applied and I would like to update the query and return it with the same variables. I found in the docs that updateQueries has an option to include queryVariables which are the last set of variables that the query was executed with. I have not found anything that describes how to retrieve the queryVariables or something like it from inside of

info argument is empty in Apollo GraphQL resolver type signature

*爱你&永不变心* 提交于 2019-12-11 06:33:41
问题 I'm working on this library https://github.com/ilyaskarim/wertik-js called Wertik JS to make GraphQL + Rest API more easily, In resolvers, when I console log info , it shows undefined. For each module, I have created dynamic resolvers to make things more easy for developers who will use this library. let object = { create: async (_:any, args:any, context:any,info: any) => { console.log(info); // This will be undefined let v = await validate(validations.create,args.input); let {success} = v;