When should I use a Relay GraphQL connection and when a plain list?

Connections More powerful and flexible than simple lists. Support pagination (forward and back), with cursors. Fine-grained mutation support (eg. RANGE_ADD, RANGE_DELETE, NODE_DELETE, as described in the guide). Requires a first or last argument in order to limit the size of the result set. Has an edges field that provides a place to locate per-edge, edge-specific … Read more

The difference between Mutation and Query

Short Conventionally: Query — for querying data (SELECT operations) Mutation — for creating new and updating/deleting existing data (INSERT, UPDATE, DELETE) Detailed Technically any GraphQL query could be implemented to cause a data write. But there is a convention that any operations that cause writes should be sent explicitly via a mutation. Besides the difference … 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 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