Skip to main content

GraphQL Service

GraphQL services let clients request exactly the data they need through a single endpoint. WSO2 Integrator supports both code-first and schema-first design, with a visual canvas for modeling types and implementing resolver logic.

Beta

GraphQL service support is currently in beta.

Creating a GraphQL service

  1. Select the + Add Artifacts button in the canvas or select + next to Entry Points in the sidebar.

  2. In the Artifacts panel, select GraphQL Service under Integration as API.

  3. In the Create GraphQL Service form, fill in the following fields:

    GraphQL Service creation form

    Service Contract

    OptionDescription
    Design From ScratchCreates a new service with an empty schema. Default selection.
    Import GraphQL SchemaGenerates resolver stubs and record types from an existing SDL (.graphql) file.

    Base Path

    FieldDescriptionDefault
    Base PathURL base path for the GraphQL service./graphql

    Port

    FieldDescriptionDefault
    PortPort on which the GraphQL service listens. Toggle between Number and Expression to enter a literal port or a configurable expression.8080

    Advanced Configurations

    Select Expand next to Advanced Configurations to set the Listener Name and other listener-level options.

  4. Select Create.

  5. WSO2 Integrator opens the service in the GraphQL diagram, an interactive canvas where you define types, fields, and resolvers. The diagram shows the service card labeled with the base path (for example, /graphql) and a + Create Operations button. Use the Configure button at the top right to edit service and listener settings, and the toolbar at the bottom left to zoom, fit, refresh, or export the diagram.

    GraphQL diagram canvas

  6. Select + Create Operations on the service card to add a Query, Mutation, or Subscription field.

  7. Select the field row to open the flow designer and define the resolver logic.

Service configuration

Service configuration controls the base path and advanced service-level settings such as maximum query depth, CORS policy, authentication, and introspection.

On the GraphQL diagram, select Configure in the service header to open the GraphQL Service Configuration panel.

FieldDescription
Service Base PathURL base path for the service (e.g., /graphql). Required.
Service ConfigurationAdvanced service-level settings (max query depth, CORS, auth, GraphiQL, etc.). Enter a @graphql:ServiceConfig record expression.

Listener configuration

The listener binds to a port and handles incoming GraphQL connections over HTTP. When you create a GraphQL service, WSO2 Integrator creates an inline listener. You can also declare a named listener or attach the service to an existing http:Listener to share a port with HTTP services.

In the GraphQL Service Configuration panel, select the attached listener under Attached Listeners to configure it.

FieldDescriptionDefault
PortListening port of the GraphQL listener. Required.9090
HostHost name or IP address the listener binds to.0.0.0.0
HTTP1 SettingsHTTP/1.x protocol settings (keep-alive, max pipelined requests).{}
Secure SocketTLS/SSL configuration. Configure to enable HTTPS.()
HTTP VersionHighest HTTP version the endpoint supports.HTTP/2.0
TimeoutRead/write timeout in seconds. Set to 0 to disable.60
ServerValue for the Server response header.()
Request LimitsInbound size limits for URI, headers, and request body.{}
Graceful Stop TimeoutGrace period in seconds before the listener force-stops.0
Socket ConfigServer socket settings (e.g., soBackLog queue length).{}

Select + Attach Listener at the bottom of the panel to attach an additional listener or to select an existing named listener.

Operations and fields

Operations define the entry points to your GraphQL service. GraphQL has three root operation types: Query (read data), Mutation (modify data), and Subscription (real-time updates). Each operation contains fields with a name, optional arguments, and a return type.

Add an operation

  1. On the GraphQL diagram, select + Create Operations on the service card.

  2. Choose Query, Mutation, or Subscription.

    GraphQL operations panel

Add a field

Select the + next to an operation type to open the Add Field panel.

FieldDescription
Field NameName of the field
DescriptionDocumentation of the field
ArgumentsInput arguments. Select + Add Argument to add an argument.
Field TypeReturn type of the field

Add Field panel

Add an argument

Select + Add Argument to open the Argument form.

FieldDescription
Argument TypeType of the argument. Select the text area to open the type helper. Input objects and enums can be added with + Create New Type.
Argument NameName of the argument
DescriptionDocumentation of the argument (optional)
Default ValueDefault value (optional). Expand Advanced Configurations to set one.

Select Add to save the argument.

Define types

A type is the fundamental unit of a GraphQL schema. Each field returns a value of a specific type, and each argument accepts a value of a specific type.

  1. Select the Argument Type or Field Type text area to open the type helper.

  2. Choose a pre-defined scalar, or select Create New Type to define a custom type.

  3. In the Create New Type dialog, choose Create from scratch to define the type inline, or Import to import it from an existing source. Select the Kind, give the type a Name, add its fields, and select Save.

    Create new type dialog

The available kinds depend on where the type is used:

Used asAllowed kinds
Argument typeInput Object, Enum
Field (output) typeObject, Enum, Union

Advanced Options for a new Argument type include Allow Additional Fields, Is Readonly Type, and Accessible by Other Integrations.

ID type

If the selected argument or field type can be marked as an ID, a checkbox appears in the type helper.

Subscription return types

Subscription field types must be wrapped with stream. For example, stream<NewsUpdate, error?>.

Implement resolver logic

  1. Select a Field row (for example, product or createProduct) to open the flow designer.
  2. Select + below the start node to open the Node palette, where you can select any node, including connections and variables.

Field-level configuration

Select the pencil icon on a Field row to return to the field edit form, and expand Advanced Configurations to access:

FieldDescription
Field ConfigurationField-level settings such as cache configuration
Request ContextPass meta-information of a request between resolvers
Field MetadataAccess meta-information of the executing field

What's next

  • GraphQL Tool — generate services and clients from SDL schemas
  • gRPC Service — define services using Protocol Buffers
  • Connections — configure client connections to call external services
  • Data Mapper — transform request and response payloads between formats