Skip to main content

GraphQL client tutorial

GraphQL provides a rich client and tooling experience for consuming data from a compliant service. RAPID makes it easy to build rich, interoperable, enterprise-ready, standards-based services.

Since RAPID services comply with the OData protocol, they can be used with tooling that targets OData services, such as GraphQL Mesh.

In this tutorial we'll see how easy it is to take advantage of GraphQL's client and tooling experiences with your RAPID service using the GraphQL Mesh OData Handler.

Create a new node.js project

  1. Install node.js
  2. Install npm package manager
  3. Create a fresh directory containing a file named "package.json" containing an open and close bracket: {}.

Install the GraphQL Mesh OData Handler

First, install the GraphQL Mesh framework as follows

npm install graphql @graphql-mesh/cli

Next, add the OData Handler:

npm install @graphql-mesh/odata

Configure the OData Handler

Create a GraphQL Mesh Configuration file named .meshrc.yaml at the root of your project, with a pointer to your RAPID service. The following configuration references our Jetsons Sample Service, but you can replace the name and baseUrl with a pointer to your own RAPID service.

- name: Jetsons

More informaton on configuring the Handler can be found in the OData Handler Documentation.

Preview your service with GraphQL

To test using GraphQL against your service, execute the following command:

yarn mesh dev

You can now use GraphiQL to try out a dynamically generated client at http://localhost:4000

Build your client

To build a stand-alone GraphQL Client for your service, run the following commands:

yarn mesh build

You can now explore the artifacts, such as the generated GraphQL schema: schema.graphql, from the .mesh folder.

Deploy a GraphQL SDK for your client

Once you have built your GraphQL client, you can deploy it as a Gateway or Generate an SDK to call it directly from within your applications.