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.
- 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
- 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.
- In the App Connect catalog, expand the GraphQL API, then click Connect.
- 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.
- 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
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
- Make sure that the API isn't being used by any flows.
- In the App Connect catalog, expand the API and remove all accounts for the API.
- Click Remove this API.