In this lesson, you will learn how to query local and remote data in Apollo Link State in the same component.

We'll set the @client decorator on the local client State variable and set an empty Query object to get this done.

Query cache data:

TO query caches data, only need to add '@client':

const getCountQuery = gql`
{
count @client
pokemon(name: "Pikachu") {
image
}
}
`;

Set up default data for the client:

const client = new ApolloClient({
uri: "https://graphql-pokemon.now.sh",
clientState: {
defaults: {
count: 0
},
resolvers: {
Query: {}
}
}
});

Read More: https://www.apollographql.com/docs/react/essentials/local-state.html

[GraphQL] Query Local and Remote Data in Apollo Link State的更多相关文章

  1. 爬取LeetCode题目——如何发送GraphQL Query获取数据

    前言   GraphQL 是一种用于 API 的查询语言,是由 Facebook 开源的一种用于提供数据查询服务的抽象框架.在服务端 API 开发中,很多时候定义一个接口返回的数据相对固定,因此要获得 ...

  2. Knockout Grid - Loading Remote Data

    http://wijmo.com/grid-with-knockout-viewmodel-loading-remote-data/ We were hearing quite a few peopl ...

  3. fastboot 刷system.img 提示 sending 'system' (*KB)... FAILED (remote: data too large)

    华为G6-C00卡刷提示OEMSBL错误,只能线刷 ,但是官方找不到线刷img镜像,无奈 网上下了个可以线刷的工具套件 流氓ROM . 使用HuaweiUpdateExtractor(工具百度)把官方 ...

  4. The ‘Microsoft.ACE.OLEDB.12.0′ provider is not registered on the local machine. (System.Data)

    When you try to import Excel 2007 or later “.xlsx” files into an SQL Server 2008 database you may ge ...

  5. Microsoft SQL Server 17导出xlsx文件时报错:The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. (System.Data)

    导出数据时报错: 如果你是导出office 2007格式 TITLE: SQL Server Import and Export Wizard ---------------------------- ...

  6. 【转】 Pro Android学习笔记(七六):服务(1):local和remote

    文章转载只能用于非商业性质,且不能带有虚拟货币.积分.注册等附加条件.转载须注明出处:http://blog.csdn.net/flowingflying/ Android提供服务,服务是运行在后台的 ...

  7. [Vue-rx] Cache Remote Data Requests with RxJS and Vue.js

    A Promise invokes a function which stores a value that will be passed to a callback. So when you wra ...

  8. [Node.js] Proxy Requests for Local and Remote Service Parity

    High availability apps require that no distinction be made between local and remote services. Attach ...

  9. @Query Annotation in Spring Data JPA--转

    原文地址:http://javabeat.net/spring-data-jpa-query/ In my previous post on Spring Data, I have explained ...

随机推荐

  1. 【译】x86程序员手册34-9.7错误代码

    9.7 Error Code 错误代码 With exceptions that relate to a specific segment, the processor pushes an error ...

  2. q-oo-p , a piggy domain name. Very cute. boyan.zheng at foxmail.com

    Contact me.

  3. Oracle数据库存储过程练习20181212

    先创建一个测试的数据表 --测试表 CREATE TABLE TEST20181207 ( ID INTEGER PRIMARY KEY, FUND NUMBER,--上日资金 BALANCE NUM ...

  4. JS日期,金钱处理

    一丶获取两个时间的天数 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> ...

  5. python __future__ 使用

    在开头加上from __future__ import print_function这句之后,即使在python2.X,使用print就得像python3.X那样加括号使用.python2.X中pri ...

  6. ORACLE IN 与NOT IN 的性能区别

    业务问题大概可以这样描述,一个父表,一个子表,查询的结果是找到子表中没有使用父表id的记录,这种情况估计很多系统都会牵涉得到.让我们来举一个例子: 表一: 父表 parent 表二: 子表 child ...

  7. x264介绍

    x264 编辑   H.264是ITU(International Telecommunication Unite 国际通信联盟)和MPEG(Motion Picture Experts Group ...

  8. 看完这篇 你就能完全操作git 远程分支的增、删、改、查了

    最近项目中又用到了git所以在此总结一番,这篇主要针对的是怎么创建远程分支,如何删除远程分支. 首先,如何创建远程分支.将一系列前期准备工作准备完成后(创建\添加ssh): 在终端键入 git bra ...

  9. 每日命令:(13)more

    more命令,功能类似 cat ,cat命令是整个文件的内容从上到下显示在屏幕上. more会以一页一页的显示方便使用者逐页阅读,而最基本的指令就是按空白键(space)就往下一页显示,按 b 键就会 ...

  10. JavaScript关键字

    JavaScript关键字 制作人:全心全意 abstract continue finally instanceof private this boolean default float int p ...