graphql

Passing complex arguments to GraphQL mutations

爷,独闯天下 提交于 2021-01-27 05:17:29
问题 I've been using GraphQL in a Node server using graphql-js, and GraphQL has shown to be an extremely valuable abstraction, but I'm running into an issue. I often find myself needing to pass large structured objects as arguments to GraphQL mutations, using GraphQLInputObjectType . This would be fine, but GraphQL doesn't support the use of JSON notation :(. So I end up just sending a string containing the JSON, for the server to deal with. const objectStr = JSON.stringify(object).replace(new

GraphQL Documentation Explorer not showing in browser .net core 3.1

女生的网名这么多〃 提交于 2021-01-24 09:36:32
问题 i am new to GraphQL, i have build a sample project using GraphQL which is working fine, but 'Documentation Explore' (my custom schema) not loaded in Browser .net core 3.1 also attached StartUp.cs . note : Which was works in .net core 2.0. here is startup.cs using GraphiQl; using GraphQL; using GraphQL.Server; using GraphQL.Types; { public class Startup { public void ConfigureServices(IServiceCollection services) { services.Configure<IISServerOptions>(options => { options.AllowSynchronousIO =

GraphQL: how can I throw a warning after a successful mutation?

早过忘川 提交于 2021-01-22 03:19:44
问题 Let's imagine I have a createPost mutation that inserts a new post. In a typical app, that mutation can either: Succeed, returning a Post . Fail, throwing an error (I use apollo-errors to handle this). What I'd like to implement is a middle scenario, where the mutation succeeds (returning a Post ); but also somehow returns a warning to the user (e.g. Your post is similar to post XYZ or similar). What would be a good GraphQL pattern to implement this? Adding a warning field to the Post type

GraphQL: how can I throw a warning after a successful mutation?

筅森魡賤 提交于 2021-01-22 03:19:17
问题 Let's imagine I have a createPost mutation that inserts a new post. In a typical app, that mutation can either: Succeed, returning a Post . Fail, throwing an error (I use apollo-errors to handle this). What I'd like to implement is a middle scenario, where the mutation succeeds (returning a Post ); but also somehow returns a warning to the user (e.g. Your post is similar to post XYZ or similar). What would be a good GraphQL pattern to implement this? Adding a warning field to the Post type

GraphQL: how can I throw a warning after a successful mutation?

风流意气都作罢 提交于 2021-01-22 03:19:12
问题 Let's imagine I have a createPost mutation that inserts a new post. In a typical app, that mutation can either: Succeed, returning a Post . Fail, throwing an error (I use apollo-errors to handle this). What I'd like to implement is a middle scenario, where the mutation succeeds (returning a Post ); but also somehow returns a warning to the user (e.g. Your post is similar to post XYZ or similar). What would be a good GraphQL pattern to implement this? Adding a warning field to the Post type

GraphQL : the object name is defined in resolvers, but not in schema

大城市里の小女人 提交于 2021-01-21 06:47:41
问题 I want to define a mutation using graphql. My mutation is getting an object as argument. So I defined the new Object in the schema and in the resolver using GraphQLObjectType. However I m getting this error : Error: Agreement.name defined in resolvers, but not in schema Any idea ? Here is my Schema definition const typeDefs = ` type Agreement { id: Int } type Mutation { agreementsPost(agreement: Agreement) : String } `; And Here is my resolver : const appResolvers = { Agreement: new

Add an array of Objects to a mutation in apollo-react

别等时光非礼了梦想. 提交于 2021-01-21 04:14:39
问题 I am using react-apollo on the front-end and graphcool on the backend. I have a mutation that creates a tutorial like so: const CREATE_TUTORIAL_MUTATION = gql` mutation CreateTutorialMutation( $author: String $link: String $title: String! $postedById: ID! $completed: Boolean! ) { createTutorial( author: $author link: $link title: $title postedById: $postedById completed: $completed ) { author link title postedBy { id name } completed } } ` It gets called in a submit handler like so... this

Add an array of Objects to a mutation in apollo-react

只谈情不闲聊 提交于 2021-01-21 04:13:08
问题 I am using react-apollo on the front-end and graphcool on the backend. I have a mutation that creates a tutorial like so: const CREATE_TUTORIAL_MUTATION = gql` mutation CreateTutorialMutation( $author: String $link: String $title: String! $postedById: ID! $completed: Boolean! ) { createTutorial( author: $author link: $link title: $title postedById: $postedById completed: $completed ) { author link title postedBy { id name } completed } } ` It gets called in a submit handler like so... this

In GraphQL, can you change the structure of the output in an alias?

左心房为你撑大大i 提交于 2021-01-20 09:04:24
问题 Let's say I've got a GraphQL query that looks like this: query { Todo { label is_completed id } } But the client that consumes the data from this query needs a data structure that's a bit different- e.g. a TypeScript interface like: interface Todo { title: string // "title" is just a different name for "label" data: { is_completed: boolean id: number } } It's easy enough to just use an alias to return label as title . But is there any way to make it return both is_completed and id under an

How to use distinct in GraphQL query?

╄→гoц情女王★ 提交于 2021-01-19 19:30:32
问题 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