Skip to main content

Start from scratch

A GraphQL API proxy operates based on the GraphQL query language specification. GraphQL provides a flexible and efficient approach to API development by allowing clients to request exactly the data they need, nothing more and nothing less.

Unlike traditional REST APIs that require multiple endpoints for different resources, GraphQL uses a single endpoint and a type system to define the API's capabilities. This enables clients to compose complex queries that fetch related data in a single request, reducing over-fetching and under-fetching of data. GraphQL is ideal for applications that need flexible data fetching and efficient data aggregation.

This walks you through creating a GraphQL API using a sample backend, deploying it to a gateway, testing it, and publishing it to a portal.

Prerequisites​

  1. Go to the API Control Plane and sign in with Google or GitHub.
  2. Open your organization, then select the Default Project or create a new project.

Create the API​

  1. On the project home page, click Create API.

  2. Select GraphQL API, then choose Start from scratch.

  3. Under Backend endpoint, enter your backend URL in the Endpoint URL field, or click Try with Sample URL to use the Countries sample service.

    The sample URL is:

    https://countries.trevorblades.com/graphql

    When introspection succeeds, the page displays Introspection enabled · SDL fetched, indicating that the console has retrieved the GraphQL schema.

  4. Click Continue.

  5. On the Configure and create page, review the generated values. The sample endpoint populates the fields as follows:

    FieldExample value
    NameCountries
    Identifiercountries
    Version1.0
    Context/countries/v1.0/graphql
    DescriptionOptional. The console leaves it empty.
    Query and Mutation URLhttps://countries.trevorblades.com/graphql

    Ensure that the Identifier is unique across your organization. Update the generated values if needed.

  6. Click Create.

Deploy the API​

Deploying places a build of the API on a gateway so requests can reach the backend through that gateway.

  1. Choose a gateway. Your organization has a cloud gateway named Default, in the development environment. To deploy to another gateway, create it first. See Manage Gateways.
  2. Go to the Deploy section and deploy the API to the gateway. For more information, see Deploy an API.

Test the API​

After deploying the API, test its operations to verify that requests can be sent through the gateway.

  1. In the left navigation menu, click Test.
  2. Use the GraphQL Console to execute queries against the deployed API and inspect the responses.

For more information, see the GraphQL Console guide.

Publish the API​

Publishing makes the API available to developers through a portal, where they can discover the API and access its documentation.

  1. Create a portal first if the organization does not have one. See Manage Portals.
  2. Publish the API. See Publish an API.

Next Steps​

Was this page helpful?