FAQs
Frequently Asked Questions about API Connect for GraphQL
- How do I set up IBM API Connect for GraphQL as a managed service on IBM Integrated webMethods Hybrid Integration (IWHI)?
- To set up IBM API Connect for GraphQL as a managed service, you need:
- An IBM IWHI account with an active subscription
- Provision the IBM API Connect for GraphQL capability in IBM IWHI (requires iPaaS admin or owner privileges)
- After provisioning, access your environment by clicking the IBM API Connect for GraphQL link in the 'My capabilities' section on the home page
- Then use the CLI tool to build, deploy, and test your GraphQL schemas
- What are the prerequisites for creating a GraphQL API using IBM API Connect for GraphQL in IWHI?
-
- An IBM iPaaS account with an active subscription
- A provisioned service instance (environment)
- Appropriate user role assigned by your administrator
- Node.js runtime installed on your machine
- IBM API Connect CLI tools installed
- Account credentials (account name, domain, admin key, and API key)
- How do I install and configure the CLI for API Connect for GraphQL?
-
- Install Node.js from nodejs.org (required for running the CLI)
- Install the CLI via npm:
npm install -g stepzen - Log in to your environment using
instance ID- For administrators (service owners):
When prompted, enter your admin key or IBM SaaS Console API key.stepzen login <domain> -i <instance_id> - For service users:
stepzen login -i <instance_id> -k <mcsp_apiKey>
- For administrators (service owners):
- Initialize your workspace:
stepzen init - Deploy your schema:
stepzen deploy - (Optional) Customize CLI configuration as needed. For more information, see Configuring the schema.
- How do I create a GraphQL schema?
-
There are two ways to create a GraphQL schema:
- Auto-generate using the CLI:
- Use
stepzen importcommands to introspect your backend data sources - Supports REST APIs, MySQL, PostgreSQL, and GraphQL backends
- The CLI automatically generates the schema
- Use
- Write manually using SDL:
- Create a .graphql file using GraphQL Schema Definition Language (SDL)
- Use custom directives to connect to backends:
@restfor REST APIs@dbqueryfor SQL databases@graphqlfor GraphQL APIs@materializerfor advanced field resolution
Deploy your schema:
- Run
stepzen deployto deploy your schema to the server - Test your API using the GraphiQL explorer (web or local)
For more information, see Creating a GraphQL schema.
- Auto-generate using the CLI:
- What are custom directives and how can I use them to connect data sources?
-
Custom directives are declarative annotations in your GraphQL schema that extend functionality and simplify how you build GraphQL APIs. IBM API Connect for GraphQL provides several custom directives for connecting to backend data sources:
Primary Connection Directives:
@rest- Connects to REST APIs-
type Query { customer(id: ID): Customer @rest(endpoint: "https://api.example.com/customers/$id") } @dbquery- Connects to SQL databases (MySQL, PostgreSQL, Oracle, Db2, etc.)-
type Query { orders(customerId: ID): [Order] @dbquery(type: "mysql", table: "orders") } @graphql- Connects to other GraphQL APIs-
type Query { spacexMissions: [Mission] @graphql(endpoint: "https://api.spacex.land/graphql") }
Advanced Directives:
@materializer- Links types and stitches data from multiple sources-
Important: Does NOT directly connect to backends
extend type Customer { orders: [Order] @materializer(query: "orders", arguments: [{name: "customerId", field: "id"}]) }This executes the existing orders query using data from the Customer type.
@sequence- Executes multiple queries in sequence-
Mixes data from multiple sources
These directives enable seamless, declarative data integration without writing resolver code. For more information, see Custom directives.
- Which backend data sources are supported?
-
IBM API Connect for GraphQL supports the following backend data sources:
RESTful APIs:
- Any REST API
- REST interfaces on NoSQL databases
Relational Databases:
- MySQL
- PostgreSQL
- Oracle
- DB2
- Microsoft SQL Server (MSSQL)
- Snowflake
- Trino
- Presto
- SingleStore
GraphQL APIs:
- Third-party GraphQL endpoints
- Other GraphQL APIs
SOAP/XML:
- SOAP services (via
@restdirective with postbody)
Connection Methods:
- Use
@restdirective for REST APIs and SOAP - Use
@dbquerydirective for SQL databases - Use
@graphqldirective for GraphQL APIs - Use
stepzen importCLI commands to auto-generate schemas
- How do I connect IBM API Connect for GraphQL to a MySQL or PostgreSQL database?
-
There are two methods to connect to MySQL or PostgreSQL databases:
Method 1: Auto-Generate (Recommended)
Use the CLI to automatically introspect your database and generate the GraphQL schema:
# For MySQL stepzen import mysql # For PostgreSQL stepzen import postgresqlThe CLI will:
- Prompt for database connection details
- Introspect your database tables and columns
- Auto-generate GraphQL types and queries
- Create config.yaml with database configuration
Then deploy with:
stepzen startMethod 2: Manual Schema with @dbquery Directive
- Create a .graphql file with your schema using the
@dbquerydirective - Create a config.yaml file with database credentials (DSN for MySQL, URI for PostgreSQL)
- Deploy with
stepzen start
For detailed step-by-step instructions, see:
- How do I deploy an endpoint with any datasource?
-
To deploy your GraphQL endpoint with any datasource, use the StepZen CLI command:
stepzen deployThis command will:
- Package your GraphQL schema files
- Upload them to the IBM API Connect for GraphQL server
- Deploy your endpoint and make it accessible via the GraphQL API
- Provide you with the endpoint URL for testing and integration
- How do I use MCP endpoint of API Connect for GraphQL?
-
To use the MCP (Model Context Protocol) endpoint with IBM API Connect for GraphQL:
- Ensure you have the MCP endpoint URL for your API Connect for GraphQL instance
- Configure your MCP client to connect to the endpoint
- Use the MCP protocol to interact with your GraphQL APIs
- How do I use IBM API Connect for GraphQL with imported GraphQL APIs?
-
You can integrate existing GraphQL APIs into IBM API Connect for GraphQL using the
@graphqldirective or the CLI import command:Method 1: Using the CLI (Recommended)
stepzen import graphql <graphql-endpoint-url>This will:
- Introspect the remote GraphQL API
- Auto-generate the schema with
@graphqldirectives - Create the necessary configuration files
Method 2: Manual Schema Definition
Create a .graphql file and use the
@graphqldirective to connect to the external GraphQL API:type Query { spacexMissions: [Mission] @graphql( endpoint: "https://api.spacex.land/graphql" query: "query { launches { mission_name } }" ) }Benefits:
- Combine multiple GraphQL APIs into a unified schema
- Add custom business logic and transformations
- Implement security and access control
- Stitch data from GraphQL APIs with REST APIs and databases
After creating your schema, deploy with:
stepzen deploy - How does IBM API Connect for GraphQL support GraphQL API development?
-
IBM API Connect for GraphQL provides comprehensive support for GraphQL API development through multiple features and capabilities:
Schema Development:
- Auto-generation: Use CLI commands to automatically generate schemas from existing data sources (REST APIs, databases, GraphQL APIs)
- Manual authoring: Write schemas using GraphQL Schema Definition Language (SDL) with custom directives
- Schema stitching: Combine multiple data sources into a unified GraphQL API
Custom Directives:
@rest- Connect to REST APIs@dbquery- Connect to SQL databases@graphql- Connect to other GraphQL APIs@materializer- Link types and stitch data@sequence- Execute queries in sequence
Development Tools:
- CLI: Command-line interface for schema management, deployment, and testing
- GraphiQL Explorer: Interactive query testing and documentation
- Local development: Test schemas locally before deployment
Security and Access Control:
- API key authentication
- JWT-based authentication
- Field-level access policies
- Role-based authorization
Deployment and Management:
- Simple deployment with
stepzen deploy - Environment management
- Version control support
- Configuration management via config.yaml
- How do I transform an existing REST API into a GraphQL API using IBM API Connect for GraphQL?
-
Method 1: Auto-Generate (Recommended)
-
Import the REST API using the CLI:
stepzen import curl "https://api.example.com/endpoint" \ --header "Authorization: Bearer YOUR_TOKEN"This introspects the REST API and automatically generates a GraphQL schema.
-
Deploy the schema:
stepzen deploy
Method 2: Manual Schema Definition
-
Create a .graphql file and define your schema using SDL with the
@restdirective:type Customer { id: ID name: String email: String } type Query { customer(id: ID!): Customer @rest(endpoint: "https://api.example.com/customers/$id") customers: [Customer] @rest(endpoint: "https://api.example.com/customers") } -
Deploy the schema:
stepzen deploy
Key Points:
- Use
@restdirective (NOT@materializer) to map REST endpoints to GraphQL fields - The
@restdirective handles the HTTP calls to your REST API - You can pass parameters, headers, and configure the endpoint URL
- Your REST data is now accessible through GraphQL queries
-
- How do I secure my GraphQL schemas and endpoints in API Connect?
-
IBM API Connect for GraphQL provides multiple security mechanisms:
- CLI Authentication Security
- Secure login for service users using MCSP credentials:
stepzen login -i <instance_id> -k <mcsp_apiKey>This method secures the CLI session itself before you can deploy or manage schemas.
- Secure login for service users using MCSP credentials:
- API Keys (Default - Simplest)
- Use Admin Keys for development (full access)
- Use API Keys for production (execute queries only)
- Pass via Authorization header:
Authorization: Apikey YOUR_KEY
- JWT-Based Authentication
- Configure JWT verification in config.yaml using JWKS endpoint or keys
- Pass JWT via Authorization header:
Authorization: Bearer YOUR_JWT - Access JWT claims in field policies for authorization
- Field Policies (Fine-Grained Control)
- Define access rules for specific fields in config.yaml
- Control access based on:
- Public access (
condition: true) - JWT presence (
condition: "?$jwt") - JWT claims/roles (
condition: '$jwt.CUSTOM.role: String == "admin"')
- Public access (
- Implement custom authorization logic without code
- GraphQL Configuration
- Disable introspection in production for security
- Control response formatting
Example config.yaml:
deployment: identity: jwksendpoint: https://your-idp.com/.well-known/jwks.json graphql: introspection: false access: policies: - type: Query rules: - fields: [publicData] condition: true - fields: [adminData] condition: '$jwt.role: String == "admin"' policyDefault: condition: "?$jwt"Important: Admin Keys and API Keys bypass all field policies and provide full access. - CLI Authentication Security
- What authentication methods are supported?
-
You can secure your GraphQL APIs using the following authentication methods:
- API keys – for general client authentication.
- JWT tokens – for secure, token-based access control.
- Admin keys – for privileged or administrative operations.
- How do I secure sensitive credentials using the --secrets flag in IBM API Connect for GraphQL?
-
In modern GraphQL development with IBM API Connect for GraphQL (StepZen), integrating with backend services such as REST, GraphQL, or database endpoints often requires sensitive credentials like API keys, authorization tokens, or custom headers. The
--secretsflag ensures these credentials are never written into generated schema files and are instead managed securely in your configuration.Why you must use --secrets
Without
--secrets, any header you pass to an import command—even a temporary test value—gets hardcoded into your .graphql file:# ❌ Exposed in your schema file! type Query { myQuery: Root @rest( endpoint: "https://myapi.com/v1" headers: [{ name: "Authorization", value: "Bearer 12345-THIS-SECRET-IS-EXPOSED" }] ) }The
--secretsflag eliminates this issue by replacing sensitive data with variable references during the introspection process.What happens when you use --secrets
Action with --secrets Security Benefit Replaces Value in SDL Prevents credentials from being committed to source control Stores Value in config.yaml Centralizes secrets in a non-schema file, making management easier Uses a Generated Variable The GraphQL schema only sees a reference, not the raw secret How to use the --secrets flag
Pass the name of the header (or URL parameter) whose value you want to hide to the
--secretsflag.1. Importing a REST API with a secret header
stepzen import curl https://my-backend.com/api/v1/user \ --header 'Authorization: Apikey 12345-THIS-IS-A-SECRET' \ --secrets 'Authorization'2. Importing a GraphQL API with a secret header
stepzen import graphql https://your-graphql-endpoint/graphql \ --header 'X-API-KEY: MySuperSecretKey' \ --secrets 'X-API-KEY'What happens behind the scenes
When you use
--secrets, StepZen automatically updates two files:The generated config.yaml:
The actual secret value is securely placed in your config.yaml file under a unique, automatically generated variable name:
configurationset: - configuration: # StepZen inserts the raw value here: authorization_416efbc0dc: Apikey 12345-THIS-IS-A-SECRET name: curl_import_configThe corresponding secure SDL:
The generated .graphql schema file now references this variable instead of the raw secret:
type Query { myQuery: Root @rest( endpoint: "https://my-backend.com/api/v1/user" # The value is now a secure variable reference! headers: [{ name: "Authorization", value: "$authorization_416efbc0dc" }] configuration: "curl_import_config" ) }Important: Notice the raw API key is nowhere in the schema!Multiple secrets example
You can secure multiple headers or parameters at once:
stepzen import graphql https://example.com/graphql \ --header 'Authorization: Apikey 1234' \ --header 'token: my-token-value' \ --secrets 'Authorization' \ --secrets 'token'Key takeaways
- Always use
--secretswhen importing data sources that require API keys or tokens. - Manage credentials securely via config.yaml instead of schema files.
- Helps ensure your GraphQL APIs comply with enterprise security standards.
- Add config.yaml to .gitignore to prevent committing secrets to version control.
- Always use