graphql

Implement GraphQL & Flutter

非 Y 不嫁゛ 提交于 2021-02-18 03:39:00
问题 Is there a way to implement GraphQL in flutter? I was trying making the API call with the query and variables objects in a JSON object. type '_InternalLinkedHashMap' is not a subtype of type 'String' in type cast 回答1: I have been using graphql_flutter package for a few weeks now and it seems to work well enough. Here is an example: import 'package:graphql_flutter/graphql_flutter.dart' show Client, InMemoryCache; ... Future<dynamic> post( String body, { Map<String, dynamic> variables, }) async

Implement GraphQL & Flutter

穿精又带淫゛_ 提交于 2021-02-18 03:38:06
问题 Is there a way to implement GraphQL in flutter? I was trying making the API call with the query and variables objects in a JSON object. type '_InternalLinkedHashMap' is not a subtype of type 'String' in type cast 回答1: I have been using graphql_flutter package for a few weeks now and it seems to work well enough. Here is an example: import 'package:graphql_flutter/graphql_flutter.dart' show Client, InMemoryCache; ... Future<dynamic> post( String body, { Map<String, dynamic> variables, }) async

How to conditionally include an argument in a GraphQL query?

不羁岁月 提交于 2021-02-17 06:00:46
问题 I have the following GraphQL query (using Apollo Client JS): query GetUsers($searchFilter: String) { users( first: 10, filter: { search: $searchFilter } ) { nodes { id name } } } This works well when I pass in the $searchFilter argument. However, I want this $searchFilter argument to be optional . So when it's null it doesn't apply the filter. This seems simple enough, but the API requires the search to be non-nullable. So passing in filter: { search: null } is not allowed. I would like to

Passing data through a GRAPHQL Subscription gives null on only one of the arguments

泄露秘密 提交于 2021-02-17 05:23:34
问题 I have the following GRAPHQL subscription: Schema.graphql type Subscription { booking: SubscriptionData } type SubscriptionData { booking: Booking! action: String } And this is the resolver subsrciption file Resolver/Subscription.js const Subscription = { booking: { subscribe(parent, args, { pubsub }, info) { return pubsub.asyncIterator("booking"); } } }; export default Subscription; Then I have the following code on the Mutation in question pubsub.publish("booking", { booking: { booking },

GraphQL入门

廉价感情. 提交于 2021-02-12 18:50:07
mkdir graphqljs cd graphqljs npm init npm install --save graphql touch hello.js 编辑hello.js var { graphql, buildSchema } = require('graphql'); var schema = buildSchema(` type Query{ hello:String }`); var root = { hello: () => 'Hello world!' }; graphql(schema, '{hello}', root).then((response) => { console.log(response); }) 运行代码 node hello 来源: oschina 链接: https://my.oschina.net/u/579683/blog/1845114

GraphQL搭配MongoDB入门项目实战

浪尽此生 提交于 2021-02-12 18:15:32
什么是GraphQL GraphQL 是一种面向 API 的查询语言。在互联网早期,需求都以 Web 为主,那时候数据和业务需求都不复杂,所以用 RestAPI 的方式完全可以满足需求。但是随着互联网的发展,数据量增大,业务需求多变。还有各种客户端需要接口适配,基于 RestAPI 的方式,显得越来呆板,因此 GraphQL 便应运而生。它至少可以提供以下三个方面的优势 GraphQL 提供更方便的 API 查询 不同的客户端有时候需要返回的数据格式不同,之前使用 RestAPI 的方式,需要后端针对每一个客户端提供单独的接口。随着业务需求的增加,维护的成本随机呈指数级跃升。而使用 GraphQL 就比较开心了,只需要写一套接口即可 解决前后端过于依赖 在开发的过程中,前端需要和后端反反复复确认各个字段,防止到时候开发到一半,因为没有对好字段,要大块大块地改代码。现在有 GraphQL 就比较方便了,你需要什么类型的字段,就自己写对应的查询语法 节约网络和计算机内存资源 之前通过 RestAPI 的方式写接口,有一个很大的问题在于,对于接口的定义,需要前期做大量的工作,针对接口做各种力度的拆分,但即使这样,也没办法应对需求的风云突变。有时候需要返回的仅仅是某个用户的某一类型的数据,但不得不把该用户的其他信息也一并返回来,这既浪费了网络的资源,也消耗了计算机的性能。显然不够优雅

翻译 | 《JavaScript Everywhere》第2章 项目简介(^_^)

不羁的心 提交于 2021-02-11 20:55:52
翻译 | 《JavaScript Everywhere》第2章 项目简介(^_^) 写在最前面 大家好呀,我是毛小悠,是一位前端开发工程师。正在翻译一本英文技术书籍。 为了提高大家的阅读体验,对语句的结构和内容略有调整。如果发现本文中有存在瑕疵的地方,或者您有任何意见或者建议,可以在评论区留言,或者加我的微信:code_maomao,欢迎相互沟通交流学习。 (σ゚∀゚)σ..:*☆哎哟不错哦 第2章 项目简介 想象一下,你站在当地的一家小餐馆的店铺前,决定在那里点一个三明治。服务员把你点的菜都写在一张纸上,然后把纸递给厨师。厨师阅读订单,使用单独的配料来制作三明治,并将三明治交给服务员。服务员会把三明治拿给你吃。如果你想要一些甜点,这个过程会再次重复。 应用程序编程接口(API)是一组规范,它允许一个计算机程序与另一个计算机程序进行交互。 Web API的工作方式与订购三明治的方式几乎相同。客户端请求一些数据,该数据通过超文本传输协议(HTTP)传输到Web服务器应用程序,Web服务器应用程序接受请求并处理数据,然后将数据通过HTTP发送给客户端。在本章中,我们将探讨Web API的广泛内容,并通过将starter API项目克隆到本地计算机上来开始我们的开发。但是,在进行此操作之前,让我们先探讨将要构建的应用程序的需求。 在本书中

Golang GraphQL MongoDB Struggling to get date and id out of the Database

喜欢而已 提交于 2021-02-11 15:40:51
问题 I am new to Golang and Graphql so I probably messed a lot of the configuration up but I am struggling to get values returned from my database using the GraphQL API I created. Whenever I query my database using the GraphQL API I created in Golang It throws the error cannot decode UTC datetime into a string type and struggles to get the id out. Here is my GrapqhQL schema: type User { _id: ID! username: String! passwordHash: String! email: String! userInfo: userStats profileStats: profileInfo }

How to access current_user with devise-token_authenticatable gem?

孤街浪徒 提交于 2021-02-11 15:27:16
问题 I’m working on a small project that is using devise and devise-token_authenticatable in a Rails/GraphQL/Apollo/React setup. Project is setup using webpacker , so the front and back ends are both served from the same domain. Sign-in, register, log-out are all handle by the front end (React). I also need to point out this is not an API only app. It seems, server is not setting the current_user or the proper cookie and I’m getting a network error. Heroku logs shows the following error:

How to access current_user with devise-token_authenticatable gem?

可紊 提交于 2021-02-11 15:26:26
问题 I’m working on a small project that is using devise and devise-token_authenticatable in a Rails/GraphQL/Apollo/React setup. Project is setup using webpacker , so the front and back ends are both served from the same domain. Sign-in, register, log-out are all handle by the front end (React). I also need to point out this is not an API only app. It seems, server is not setting the current_user or the proper cookie and I’m getting a network error. Heroku logs shows the following error: