How to use IBM App Connect with imported GraphQL APIs

GraphQL is a query language for APIs and a runtime that runs queries with your own data.

By providing a description of the data in your API, GraphQL helps you to retrieve the data that you need. You can import GraphQL schemas as APIs to IBM® App Connect and use them as stand-alone connectors in your flows. For more information, see Introduction to GraphQL in the GraphQLdocumentation.

The imported GraphQL API connector provides a wrapper for the GraphQL Schema Definition Language (SDL) and connects seamlessly to run actions that are defined in GraphQL. This connector supports the following features.
Query and mutation
In GraphQL, queries are used to retrieve data from the server. Queries facilitate efficient data retrieval because clients use them to specify the exact data that they need. Mutations modify data on the server, such as creating, updating, or deleting records. Both queries and mutations are defined in the GraphQL schema and use resolvers to run the requested operations, which result in precise and flexible data interactions.
SDL from StepZen
StepZen's SDL approach allows developers to build and run GraphQL APIs efficiently by using a directive-driven method. You can use this SDL-first approach to define the schema by using GraphQL SDL files. These SDL files are then enhanced with powerful GraphQL directives such as @rest, @dbquery, and @graphql to connect and configure various backend data sources like REST, databases, and other GraphQL services. For more information, see Write GraphQL schemas with custom directives.
SDL with default entry types for query and mutation
You can use the SDL in GraphQL to define the structure of your API, including types, queries, mutations, and their relationships. SDL is written in a syntax that is human readable, making it straightforward to define the capabilities of your GraphQL API. In GraphQL SDL, the root operation types for querying and modifying data are query and mutation. These types serve as the entry points for client operations.

GraphQL restrictions

The GraphQL APIs that you can import into App Connect have the following restrictions.
  • GraphQL subscriptions are not supported.
  • Schemas are allowed for the GraphQL that is hosted on StepZen and not from any independent source. Currently, supported data sources include MySQL and MongoDB.
  • Batch processing is not supported.
  • The .graphql file size must not exceed 3 MB.

Importing a GraphQL API to App Connect

Import the GraphQL API into the App Connect catalog by following the instructions in Importing a GraphQL API.

Connecting App Connect to an imported GraphQL API

To create a flow that passes data between imported GraphQL APIs and applications or APIs in the catalog, connect App Connect to the GraphQL API connector, API, and application in the flow. You can connect from the catalog, or when you add the GraphQL API connector, API, or application to a flow.

The connection values that you need are based on the security scheme that is configured for the GraphQL API connector and whether the endpoint is publicly available or private.

You can connect to the GraphQL API connector from the flow editor when you add it as a target application to a flow. The following steps describe how to connect to the API from the App Connect catalog for the first time.
  1. In the App Connect catalog, expand the GraphQL API, then click Connect.
  2. Complete the following connection fields.
    Note: The GraphQL API connector supports the API KEY authorization type only.
    • Set the GraphQL server URL field to the GraphQL server URL for your GraphQL service.
    • Set the API key field to the unique API key that identifies the API client.
    Filled in connection fields for a GraphQL connector
  3. Click Connect.

    An account is created in App Connect, and the API moves to the section of connected connectors in the catalog. By default, the account is named Account 1, but you can use the Account menu to rename it. For more information, see Managing accounts

    You can now use the imported API as a target application in your flows.

Adding an imported GraphQL API to a flow

Note: You can add an imported API as a target application only. You can't use an imported API as a source application that triggers a flow.

When you create a flow in App Connect Designer, you can use the imported API as a target application by adding actions to call the API's operations. For more information, see Creating flows in App Connect Designer.

Other than the added actions, all imported GraphQL API connectors support the Run custom GraphQL query action.

Removing an imported GraphQL API from the App Connect catalog

To remove an imported GraphQL API from the App Connect catalog, complete the following steps.
  1. Make sure that the API isn't being used by any flows.
  2. In the App Connect catalog, expand the API and remove all accounts for the API.
  3. Click Remove this API.
'Remove this API' link for removing a GraphQL API connector from the Catalog page