In Relay, what role do the node interface and the global ID spec play?

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

How to query list of objects with array as an argument in GraphQL

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

Date and Json in type definition for graphql

Have a look at custom scalars: https://www.apollographql.com/docs/graphql-tools/scalars.html create a new scalar in your schema: scalar Date type MyType { created: Date } and create a new resolver: import { GraphQLScalarType } from ‘graphql’; import { Kind } from ‘graphql/language’; const resolverMap = { Date: new GraphQLScalarType({ name: ‘Date’, description: ‘Date custom scalar type’, parseValue(value) { … Read more

How do you prevent nested attack on GraphQL/Apollo server?

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