How to chain two GraphQL queries in sequence using Apollo Client

The props added by your firstQuery component will be available to the component below (inside) it, so you can do something like: export default compose( graphql(firstQuery, { name: ‘firstQuery’ }), graphql(secondQuery, { name: ‘secondQuery’, skip: ({ firstQuery }) => !, options: ({firstQuery}) => ({ variables: { var1: } }) }) )(withRouter(TestPage)) Notice that we … Read more

How to send graphql query by postman?

There’s a better way to do it using the REST client Insomnia Docs are here, how to send graphql queries: Below are the steps for postman Step 1. Run the GraphiQL in Chrome, open the Chrome Dev Console, click the Network tab, and make the query from graphiql, when you make the query, network … Read more

How to know which fields were requested in a GraphQL query?

You’ll need to parse the info object that’s passed to the resolver as its fourth parameter. This is the type for the object: type GraphQLResolveInfo = { fieldName: string, fieldNodes: Array<Field>, returnType: GraphQLOutputType, parentType: GraphQLCompositeType, schema: GraphQLSchema, fragments: { [fragmentName: string]: FragmentDefinition }, rootValue: any, operation: OperationDefinition, variableValues: { [variableName: string]: any }, } You … Read more

What’s the point of input type in GraphQL?

From the spec: The GraphQL Object type (ObjectTypeDefinition)… is inappropriate for re‐use [as an input], because Object types can contain fields that define arguments or contain references to interfaces and unions, neither of which is appropriate for use as an input argument. For this reason, input objects have a separate type in the system. That’s … Read more

Shouldn’t the login be a Query in GraphQL?

In the context of that example, login should be a Query instead of a Mutation assuming its resolver has no side-effects, at least according to the spec. However, there’s a couple of reasons you probably won’t see that done in the wild: If you’re implementing authentication, you’ll probably want to log your users’ account activity, … Read more

Auto-update of apollo client cache after mutation not affecting existing queries

From the docs: If a mutation updates a single existing entity, Apollo Client can automatically update that entity’s value in its cache when the mutation returns. To do so, the mutation must return the id of the modified entity, along with the values of the fields that were modified. Conveniently, mutations do this by default … Read more