graphql

How to use distinct in GraphQL query?

早过忘川 提交于 2021-01-19 19:29:02
问题 Here is query where I try to use distinct in graphQl query: query{ contacts(take: 10, distinct: true) { firstName lastName title } } But I am getting error: { "errors": [ { "message": "Unknown argument \"distinct\" on field \"contacts\" of type \"QuerySchema\".", "locations": [ { "line": 2, "column": 21 } ] } ] } 回答1: GraphQL has no built-in sorting/filtering. It is up to the server to implement features like that, so if you're relying on a third party API and it doesn't support it then you

Deploying react/apollo-server app onto Heroku

假装没事ソ 提交于 2021-01-07 03:33:08
问题 What I'm trying to do is deploy react / apollo-server full stack app to heroku. Thus I' trying to serve static client files from express/apollo-server backend, like this: const path = require('path'); const express = require('express'); const app = express(); const cors = require('cors'); const { ApolloServer } = require('apollo-server'); const { schema } = require('./schema'); const { resolvers } = require('./resolvers'); app.use(cors()); app.use(express.static('public')); app.get('*', (req,

Deploying react/apollo-server app onto Heroku

☆樱花仙子☆ 提交于 2021-01-07 03:32:04
问题 What I'm trying to do is deploy react / apollo-server full stack app to heroku. Thus I' trying to serve static client files from express/apollo-server backend, like this: const path = require('path'); const express = require('express'); const app = express(); const cors = require('cors'); const { ApolloServer } = require('apollo-server'); const { schema } = require('./schema'); const { resolvers } = require('./resolvers'); app.use(cors()); app.use(express.static('public')); app.get('*', (req,

#[apollo-cache-persist] purged cached data | apollo-cache-persist Error | apollo-cache-persist not working

半世苍凉 提交于 2021-01-07 02:37:30
问题 This is the code I have used for cache persistance using 'apollo3-cache-persist', seems to have automatically purge the cached data after initial caching. Purging causes everything in the storage used for persistence to be cleared. Hence resulting in not persisting. import { persistCache, LocalStorageWrapper, LocalForageWrapper } from 'apollo3-cache-persist'; const httpLink = createHttpLink({ uri: 'http://localhost:4000/' }); const cache = new InMemoryCache(); persistCache({ cache, storage:

#[apollo-cache-persist] purged cached data | apollo-cache-persist Error | apollo-cache-persist not working

北城以北 提交于 2021-01-07 02:36:51
问题 This is the code I have used for cache persistance using 'apollo3-cache-persist', seems to have automatically purge the cached data after initial caching. Purging causes everything in the storage used for persistence to be cleared. Hence resulting in not persisting. import { persistCache, LocalStorageWrapper, LocalForageWrapper } from 'apollo3-cache-persist'; const httpLink = createHttpLink({ uri: 'http://localhost:4000/' }); const cache = new InMemoryCache(); persistCache({ cache, storage:

Does Apollo Server work with GraphQL Tools stitchSchemas?

ε祈祈猫儿з 提交于 2021-01-07 01:36:54
问题 According to Apollo docs "Apollo Server 2 exports all of graphql-tools, so makeExecutableSchema and other functions can be imported directly from Apollo Server." "Apollo Server is able to accept a schema that has been enabled by graphql-tools" However, I've just noticed I can't directly import stitchSchemas from apollo-server (I've been using it from @graphql-tools/stitch), and am hours deep in problems that aren't making sense. Does Apollo work with stitchSchemas or not? 回答1: Yes, you can

Does Apollo Server work with GraphQL Tools stitchSchemas?

冷暖自知 提交于 2021-01-07 01:33:16
问题 According to Apollo docs "Apollo Server 2 exports all of graphql-tools, so makeExecutableSchema and other functions can be imported directly from Apollo Server." "Apollo Server is able to accept a schema that has been enabled by graphql-tools" However, I've just noticed I can't directly import stitchSchemas from apollo-server (I've been using it from @graphql-tools/stitch), and am hours deep in problems that aren't making sense. Does Apollo work with stitchSchemas or not? 回答1: Yes, you can

GraphQL:打造自己的Directive库

我是研究僧i 提交于 2021-01-06 16:49:50
GraphQL 既是一种用于 API 的查询语言也是一个满足你数据查询的运行时。GraphQL 对你的 API 中的数据提供了一套易于理解的完整描述,使得客户端能够准确地获得它需要的数据,而且没有任何冗余,也让 API 更容易地随着时间推移而演进,还能用于构建强大的开发者工具。 ——出自 https://graphql.cn HotChocolate可以通过自定义Directive来对字段的值进行转换和处理,下在的例子就是给字符串给字符串类型的值转大写和替换。 using HotChocolate; using HotChocolate.Data; using HotChocolate.Execution; using HotChocolate.Types; using System; using System.Collections.Generic; using System.Reflection; namespace GraphQLBase003 { class Program { static void Main(string[] args) { DirectiveDemo.Run(); } } public class DirectiveDemo { public static void Run() { var schema = SchemaBuilder.New()

GraphQL:从头开始

微笑、不失礼 提交于 2021-01-06 16:48:45
GraphQL 既是一种用于 API 的查询语言也是一个满足你数据查询的运行时。GraphQL 对你的 API 中的数据提供了一套易于理解的完整描述,使得客户端能够准确地获得它需要的数据,而且没有任何冗余,也让 API 更容易地随着时间推移而演进,还能用于构建强大的开发者工具。 ——出自 https://graphql.cn 前面几篇博文介绍了GraphQL在asp.net core框架下的实例,初步了解到Hot Chocolate的功能,不如从这篇开始,细致的过一下Hot Chocoklate,看看.net下这个GrpahQL框架究竟做了点什么,我们又能做点什么。 首先使用HotChocolate有两种姿势,代码姿势(code-first)和脚手架姿势(schema-first),那长什么样呢?实例送上: using HotChocolate; using HotChocolate.Execution; using HotChocolate.Types; using System; namespace GraphQLBase001 { class Program { static void Main(string[] args) { var schemaString = @" type Query { hello: String }"; Console.WriteLine(

gatsby-source-graphql + ACF fields not showing up

佐手、 提交于 2021-01-05 10:26:45
问题 I'm wondering why my ACF fields are not showing up in my gatsby app using the gatsby-source-graphql plugin? My ACF fields show up when I use the WP plugin: WP GraphiQL, but not when I run my gatsby app. Can I only import ACF fields using gatsby-source-wordpress??? Everything else seems to show up. I have a custom post type that I'm using no problem, but ACF fields are the issue. Any help would be amazing, Thanks, Spencer They show up in WP backend: But do not show up when Gatsby runs: Here is