API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Building GraphQL APIs for IBM Db2 and Oracle with API Connect for GraphQL

By Jeena Joy posted yesterday

  

In today’s data-driven world, developers need fast, flexible, and secure ways to expose enterprise data. With IBM API Connect for GraphQL , you can effortlessly create GraphQL APIs for your Db2 and Oracle databases—no boilerplate code, no complex middleware.

Whether you're modernizing legacy systems or building new digital experiences, this guide will help you get started with a unified approach for both Db2 and Oracle.

🛠️ Prerequisites

Before diving in, make sure you have:

🔐 Step 1: Log in to API Connect for GraphQL

Use your instance ID and MCSP API key to authenticate:
stepzen login us-east-a.ibm.stepzen.net -i <INSTANCE ID> -k <MCSP API KEY>

🌐 Step 2: Create Your Endpoint

Give your GraphQL API a name:
stepzen init --endpoint=api/myendpoint
This initializes your project folder and sets up the configuration.

🧬 Step 3: Import Your Backend

For Db2:

stepzen import db2

You'll be prompted for:

  • JDBC URL:

            jdbc:db2://host:port/db:user=user;password=password;sslConnection=true;currentSchema=schemaname;

  • Schema name (optional)

  • Whether to auto-link types using @materializer (choose based on your use case)

Once complete, StepZen introspects your Db2 database and generates a GraphQL schema (index.graphql) with types, queries, and mutations.

For Oracle:

stepzen import oracle

Provide your JDBC URL in this format:

jdbc:oracle:thin:[user/password]@//host[:port]/service

The CLI will introspect your Oracle database and generate the schema just like it does for Db2.

🚀 Step 4: Deploy Your Schema

Push your schema to API Connect for GraphQL:

stepzen deploy

You’ll get two URLs:

  • HTTPS endpoint for queries

  • WSS endpoint for subscriptions

Example:

✓ 🔐 https://accountname.us-east-a.ibm.stepzen.net/api/myendpoint/graphql

✓ 🔐 wss://accountname.us-east-a.ibm.stepzen.net/stepzen-subscriptions/api/myendpoint/graphql (subscriptions)

🔍 Step 5: Explore Your API

You can test your deployed API using:

Curl:

curl https://accountname.us-east-a.ibm.stepzen.net/api/myendpoint/graphql \
  --header "Authorization: Bearer $(stepzen whoami --accesstoken)" \
  --header "Content-Type: application/json" \
  --data-raw '{
    "query": "query SampleQuery { __schema { description queryType { fields {name} } } }"
  }'

GraphiQL Dashboard:

Visit: API Connect for GraphQL Dashboard Explorer section

📚 Learn More

✨ Final Thoughts

Whether you're working with Db2 or Oracle, API Connect for GraphQL make it incredibly easy to expose your data through modern GraphQL APIs. With just a few CLI commands, you can go from database to deployed endpoint—ready to power your apps, dashboards, and integrations.

Ready to give it a try? Start your free trial and build your first GraphQL API today.



 

0 comments
2 views

Permalink