How to search string values in GraphQL

The short answer is: you don’t. The longer answer is that you have to write that code yourself. GraphQL isn’t a database query language like SQL, it’s an application query language. What that means is that GraphQL won’t let you write arbitrary queries out of the box. It will only support the types of queries … Read more

How to connect GraphQL and PostgreSQL

GraphQL is database agnostic, so you can use whatever you normally use to interact with the database, and use the query or mutation’s resolve method to call a function you’ve defined that will get/add something to the database. Without Relay Here is an example of a mutation using the promise-based Knex SQL query builder, first … Read more

Cleaning Unwanted Fields From GraphQL Responses

There are three ways of doing this First way Update the client parameter like this it will omit the unwanted fields in graphql. apollo.create({ link: http, cache: new InMemoryCache({ addTypename: false }) }); Second Way By using the omit-deep package and use it as a middleware const cleanTypeName = new ApolloLink((operation, forward) => { if … Read more

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