Instant GraphQL API on Back4App

Instant GraphQL API on Back4App

After a lot of coffee and code, we are excited to announce the GraphQL support on Back4App!

Since version 3.5, Parse Server automatically provides a GraphQL API in addition to the REST API. Version 3.6 is already available as a beta at Back4App, and you can now enjoy a powerful, also instantly, generated GraphQL API, for your new or existing apps.

Sign Up now to Back4App and start to build your GraphQL API.

What is GraphQL?

GraphQL is an open-source query and data manipulation language created by the Facebook team. A fast-growing amount of organizations has adopted GraphQL for building APIs.

For more details about GraphQL take a look at this article: What is GrapjhQL

GraphQL vs. REST

The main advantages of using GraphQL instead of REST for an API include:

  • Predictable results – when using a GraphQL API, the clients need to specify their desired data, and the server returns exactly that;
  • Many resources per request – it is possible to run multiple queries or mutations in a single request when using a GraphQL API;
  • Introspective type system – a GraphQL API is organized in terms of types and fields that clients can introspect, allowing powerful features like auto-complete, instantly documentation, and data validation.

GraphQL Schema

The GraphQL schema is composed of three main types that allow different kinds of operations:

  • Query – operations that only return data from the server without changing anything;
  • Mutation – operations that can change and return data from the server;
  • Subscription – operations that work as real-time queries.

When using Parse GraphQL Server on Back4App, Parse Server automatically creates your GraphQL API schema based on your application’s classes.

GraphQL Query

Parse GraphQL Server instantly create the following queries for your GraphQL API:

  • health: check the server health;
  • objects:
    • get: get an object of any class;
    • find: find objects of any class;
    • for each existing class:
      • get<ClassName>: get an object of this specific class;
      • find<ClassName>: find objects of this specific class;
  • users:
    • me: retrieve the current logged user;

The Parse Community continue working hard to include new auto-generated GraphQL queries to the API.

GraphQL Mutation

Parse GraphQL Server instantly create the following mutations for your GraphQL API:

  • objects:
    • create: create a new object of any class;
    • update: update an existing object of any class;
    • delete: delete an existing object of any class;
    • for each existing class:
      • create<ClassName>: create a new object of this specific class;
      • update<ClassName>: update an existing object of this specific class;
      • delete<ClassName>: delete an existing object of this specific class;
  • files:
    • create: create a new file;
  • users:
    • signUp: sign up a new user;
    • logIn: log in an existing user by its credentials;
    • logOut: log out the current logged user;

The Parse Community continue working hard to include new auto-generated GraphQL mutations to the API.

GraphQL Subscription

Parse GraphQL Server does not support GraphQL subscriptions yet, but the Parse Community is working hard to include auto-generated ones as soon as possible.

 

Sign Up now to Back4App and start to build your GraphQL API.

GraphQL Playground

GraphQL Playground is an IDE to play around with a GraphQL API. Parse Dashboard has a built-in GraphQL Playground that you can use through Back4App hosting to run your GraphQL examples.

GraphQL Tutorial

Back4App is the easiest platform to get started with a GraphQL API. You just need to follow these steps:

  1. If you have already created an app at Back4App, go to the next step. Otherwise, you need to create a new app.
  2. The Parse GraphQL API is available at Back4App since version 3.6.0. Therefore, you need to manage your Parse Server version and make sure it is above or equal to 3.6.0.
  3. Visit your Parse Dashboard (refresh the page in the case it was already open), click on your app -> Core -> API Console -> GraphQL Console.

GraphQL Example

Now you are ready to run your first GraphQL query:


query Health {
  health
}

This is the expected result:



{
  "data": {
    "health": true
  }
}

Learn GraphQL

We recommend learning GraphQL through the following links:

  • GraphQL Cookbook – a series of recipes showing solutions for common problems that you might want to solve using a GraphQL API.
  • Parse GraphQL Guide – an open-source guide for Parse GraphQL API.
  • GraphQL Website – GraphQL official website that can be used to learn more about the GraphQL language power.

Additionally, we have also prepared a video series about GraphQL that you can start watching in the link below:

 

Sign Up now to Back4App and start to build your GraphQL API.


Comment ( 1 )

  1. ReplySamuel Falci
    Bom dia Davi. Tudo certo? Eu consegui fazer as querys no graphl console do parse dashboard, porém não consegui encontrar exemplos de querys feitas de dentro da aplicação, no codigo fonte. Tenho uma api parse rodando em nodejs e gostaria de construir minhas querys de la. Vc poderia me dar alguma dica por favor?

Leave a reply

Your email address will not be published.