Using GraphQL Schema

GraphQL provides a powerful query language for your APIs enabling clients to get the exact data that they need. It has the ability to get data from multiple resources in a single request by aggregating the requested data to form one result set. GraphQL provides a single endpoint for accessing data in terms of types and fields.

TIBCO Cloud Integration- Flogo (PAYG) provides an out-of-the-box GraphQL Trigger which turns your Flogo app into a GraphQL server implementation. Each Flogo flow in the app acts like a GraphQL field resolver. So the output of the flow, must match the return type of the field in the schema.

TIBCO Cloud Integration- Flogo (PAYG) allows you to create GraphQL triggers by dragging and dropping your GraphQL schema file or by navigating to the file. A flow gets automatically created for every query and mutation type in your schema. You must then open the flow and define what kind of data you want the flow to return. This saves you the time and effort to programmatically define data structures on the server.

Note: This section assumes that you are familiar with GraphQL. To learn about GraphQL, refer to the GraphQL documentation.

GraphQL server implementation in TIBCO Cloud Integration- Flogo (PAYG)

To obtain samples of GraphQL schemas and application JSON files, go to https://github.com/project-flogo/graphql.

To use GraphQL in TIBCO Cloud Integration- Flogo (PAYG), you must create a GraphQL trigger and add it to your flow. Use one of the methods below to create a GraphQL trigger.
Note: You can use only one schema per app. If you add another GraphQL Trigger to the app, you must use the same original schema.
Note: The implementation of GraphQL server in TIBCO Cloud Integration- Flogo (PAYG) currently does not return the specified field ordering in a query when a request is received. It does not affect the correctness of the response returned, but affects the readability and is non-compliant to current specification.

For details on the GraphQL Trigger refer to the "GraphQL Trigger" section in the TIBCO Flogo® Activities and Triggers Guide.

Creating the trigger during new flow creation

When you create a new flow, you have the option to select From GraphQL Schema which will generate the GraphQL trigger and attach it to the flow. To generate the GraphQL Trigger during flow creation, follow these steps:
  1. Create a file with your schema and name it with a .gql or .graphql extension.
  2. In TIBCO Cloud Integration- Flogo (PAYG), Open the app details page and click +Create.
  3. Select From GraphQL Schema in the Create flows and triggers dialog.
  4. Upload your <schema>.gql or <schema>.graphql file by either dragging and dropping it or navigating to it using the browse to upload link. TIBCO Cloud Integration- Flogo (PAYG) validates the file extension. If your file extension is either .gql or .graphql, you see a green check mark and the Upload button appears.
  5. Click Upload. TIBCO Cloud Integration- Flogo (PAYG) validates the contents of your schema and if it passes the validation, it creates the flows based on the definitions in your schema file. One flow is created for each query or mutation field in your schema.

Manually adding the trigger to an existing flow

If you have an existing flow, you can manually add a GraphQL trigger to the flow. To do so, follow these steps:
  1. Click the icon to the left of your flow.
  2. Click GraphQL Trigger in the the Add a Trigger dialog.
  3. Enter your GraphQL schema in the Enter a GraphQL Schema for the trigger box. The GraphQL Operation and Resolver For drop down menus automatically get populated based on the definitions in your schema.
  4. Select a GraphQL operation from the drop down menu.
  5. Select a resolver from the Resolver for drop down menu.
  6. Click Continue. You will now see a dialog with two options, CopySchema and Just add the trigger. Click CopySchema.
    Note: Once the trigger is created from the wizard, the trigger configuration is fixed and the Operation Field and Resolver For cannot be changed.

Limitations on constructs in a GraphQL schema

TIBCO Cloud Integration- Flogo (PAYG) currently does not supports the following GraphQL constructs:
  • Custom scalar types
  • Custom directives
  • Subscription type
  • Cyclic dependency in schema. For example, if you have a type Book which contains an object element of type, Author. The type Author in turn contains an element of type Book which represents the books written by the author. To retreive the Author, it creates a cyclic dependency where the Author object contains the Book object and the Book type in turn contains the Author object.