GraphQL Union and Input Type?
As of September 2017, this is not possible. There is an ongoing discussion around this functionality.
As of September 2017, this is not possible. There is an ongoing discussion around this functionality.
I had a look at the GraphQL spec. The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, it is not intended to be humanâreadable. While it is often numeric, it … Read more
Please replace your expressGraphQL with graphqlHTTP as it was destructured Use: const { graphqlHTTP } = require(‘express-graphql’); or const expressGraphQL = require(‘express-graphql’).graphqlHTTP This is because a method called graphqlHTTP exist in the express-graphql module and you are destructure with another method name that does not exist in the module I also noticed that you have … Read more
The buildSchema function takes a schema in SDL (schema definition language) and returns a GraphQLSchema object. Given two identical schemas generated with each method, runtime performance would be the same. Startup time for a server using buildSchema would be slower since parsing the SDL adds an extra step that would not otherwise exist — whether … Read more
I’ve come up with a middle-ground solution. Rather than trying to push this complexity onto GraphQL, I’m opting to just use the String type and JSON.stringifying my data before setting it on the field. So everything gets stringified, and later in my application when I need to consume this field, I JSON.parse the result to … Read more
Post request needs to manage headers info. Using Http client – Content-Type: application/json Using Postman client – Content-Type: application/graphql but request body looks like string {“query”:”mutation{update(id:1,x1:\”zazaz\”,x2:\”zazaz\”……){id x1 x2}}”}
The Node root field, in combination with globally unique IDs, comes into play when Relay needs to refetch an object. Refetching occurs when you call this.props.relay.forceFetch() or when you add fields to the query for an object whose global ID is known because it has already been partially fetched. In cases like these, Relay will … Read more
You can definitely query with an array of values! Here’s what the query itself would look like: { events(containsId: [1,2,3]) { … } } And the type would look something like: const eventsType = new GraphQLObjectType({ name: ‘events’, type: // your type definition for events, args: { containsId: new GraphQLList(GraphQLID) }, … }); If you … Read more
In the GraphQL spec, objects and input objects are distinct things. Quoting the spec for input objects: Fields can define arguments that the client passes up with the query, to configure their behavior. These inputs can be Strings or Enums, but they sometimes need to be more complex than this. The Object type… is inappropriate … Read more
As of the time of writing, there isn’t a built-in feature in GraphQL-JS or Apollo Server to handle this concern, but it’s something that should definitely have a simple solution as GraphQL becomes more popular. This concern can be addressed with several approaches at several levels of the stack, and should also always be combined … Read more