Support for GraphQL Assets
Overview
GraphQL is a query language designed to build client applications by providing a flexible syntax and system for describing their data requirements and interactions. Using GraphQL service, you query a specific data to the server and get the response in a predictable way.
You can deploy GraphQL assets, which are developed using Software AG Designer and on-premises webMethods Integration Server, to Cloud Deployment. You choose from predefined solution landscapes to deploy your on-premises assets from Software AG Designer.
Let us see an example of how we deploy GraphQL assets which are developed using Software AG Designer and on-premises webMethods Integration Server to Cloud Deployment.
Preconditions
Create a GraphQL Schema
Create a GraphQL schema using SDL (Schema Definition Language). A sample schema is shown below:
type Query {
dog: Dog
findDog(complex: ComplexInput): Dog
booleanList(booleanListArg: [Boolean!]): Boolean
arguments: Arguments
human: Human
pet: Pet
name: String!
Name: String!
catOrDog: CatOrDog
}
enum DogCommand { SIT, DOWN, HEEL }
type Dog implements Pet {
name: String!
nickname: String
barkVolume: Int
doesKnowCommand(dogCommand: DogCommand!): Boolean!
isHousetrained(atOtherHomes: Boolean): Boolean!
owner: Human
}
interface Sentient {
name: String!
}
Implementing GraphQL Descriptor in Integration Server and Designer
You use the Service Development perspective to create a new GraphQL descriptor based on the schema.
In the
Designer perspective, select
File > New > GraphQL Descriptor.
In the
New GraphQL Descriptor dialog box, select the folder in which you want to create the
GraphQL descriptor.
In the
Element name field, type a name for the
GraphQL descriptor using any combination of letters, numbers, and/or the underscore character.
Click
Next.
In the
Select the GraphQL Schema Location wizard, browse and select the schema file.
Note:
Ensure that the format of the schema file is .txt, .json, .graphql, or .graphqls.
Click
Finish.
Designer creates the
GraphQL descriptor and displays the details in the
GraphQL descriptor editor.
Build Resolver Services for the GraphQL Descriptor
Integration Server creates the following assets when you import a GraphQL schema:
A GraphQL descriptor with the name as provided by the user.
When you create a GraphQL descriptor using the above GraphQL schema with name Gq, then
Designer creates folders with name types and resolvers under
Gq folder like this:
All the document types are created under the types folder and all the resolver services are created under the resolvers folder.
If you import the above schema in Integration Server with name Gq, then Integration Server creates the resolver services for Query operation under Gq_/resolvers/Query folder, and the resolver services for Mutation operation under Gq_/resolvers/Mutation folder.
The resolver will have the input/output signature set.
Deploy Assets to Cloud Deployment
Using Designer, you deploy your on-premises Integration Server GraphQL packages and assets to Cloud Deployment. Before deploying the packages and assets, you must configure a connection to Integration Cloud.
Before you configure a connection to Integration Cloud, ensure that the following criteria are met:
A valid URL exists to connect to
Integration Cloud.
A valid user account is created on
Integration Cloud.
To add a connection configuration for Integration Cloud
In
Designer, select
Window >
Preferences.
In the preferences navigation tree, select
Software AG >
Integration Cloud.Click
Add.
In the
Add connection configuration dialog box, enter the following information:
Field | Description |
Name | The name to use for the Cloud Deployment connection configuration. Note: The name cannot contain control characters, special characters, and characters outside of the basic ASCII character set, such as multi-byte characters. |
URL | URL of the Cloud Deployment host to which Designer is to connect. For example, https://<sub-domain>.<domain-name>.<domain-suffix>. |
User | The user name for an account on Cloud Deployment. |
Password | The password for the specified User. |
Save password (in the Eclipse secure storage) | Indicates whether the password for the specified user account should be saved in Eclipse secure storage. Cloud Deployment uses this password from the Eclipse secure storage whenever user authorization is required. If you want to save the password in Eclipse secure storage, select this check box. |
A connection configuration is now added to the Connections page with the specified details.
To deploy assets to Cloud Deployment
1. In Package Navigator view, select the Integration Server package that you want to deploy to Cloud Deployment.
2. Right-click the GraphQl package and click Deploy to Cloud.
Verify the Deployed Assets in Cloud Deployment
After publishing the GraphQL packages to an asset repository provisioned for the tenant on Cloud Deployment, you can view and access the webMethods Integration Server packages in Cloud Deployment. The solution details page allows you to view the packages, assets, and services for GraphQL runtimes in the solution.
To view the GraphQl packages in the Solution Explorer:
1. Switch to the Cloud Deployment perspective.
2. From the Cloud Deployment navigation bar, click Solutions > Solution List.
3. Click on an existing solution. The Solution Explorer page appears.
The Solution List page appears listing GraphQL solutions.
Displaying the API details of an executable service
After deploying assets, on the Asset explorer page, click the ellipses
icon to view the API details of the service such as the HTTP Method and URL that are required to invoke this service from an external system. You copy the required API details to execute the service from the external client.
Service Execution from External Client
To execute the service from a third party tool, let us use Postman as the GraphQL client. So in this example, when we open the GraphQL client, and invoke the URL as shown below, we get the output as per the fields passed in the query.