Authors:
Ankit Mehta, Cille Schliebitz, Anita Gu
Changed on:
4 Feb 2025
In this module, you will learn about a Plugin Project structure and JS GraphQL within the Plugin Project. You will also learn how to modify and run a JS GraphQL query.
💡 Let's take a look at the project folder structure of the created plugin.
JS GraphQL plugin in IntelliJ IDE facilitate the generation of Java objects from your GraphQL queries. When you perform a maven build, such as an install or package, the JS GraphQL plugin will automatically generate a Java class based on the query. Make sure you have installed JS GraphQL Plugin in the IntelliJ. Please check the installation requirement listed in the Prerequisites section.
💡 Let's have a look at the GraphQL plugin within the Java IDE (IntelliJ).
💡 Let's configure GraphQL with a few of your Fluent Account settings.
In order to create the GraphQLConfig file, right-click on [ your - plugin project - name ] > New > GraphQL configuration file. The GraphQLConfig file should now be created inside the root project folder next to pom.xml file.
If the GraphQL configuration file option is not available — check that you have installed the JS GraphQL plugin.
Copy the code below and replace it with the code in the graphqlconfig file. You will need field values (e.g. Project Name, URL, SchemaPath) to configure the file.
1{
2"projects": {
3"<YOUR_PROJECT_NAME>": {
4"schemaPath": "src/main/graphql/<YOUR_PROJECT_GROUP_PATH>/schema.json",
5"extensions": {
6"endpoints": {
7"sandbox": {
8"url": "https://<YOUR_FLUENT_ACCOUNT_ID>.sandbox.api.fluentretail.com/graphql",
9"headers": {
10"Authorization": "Bearer ${env:AUTH_TOKEN_ENV}"
11}
12}
13}
14}
15}
16}
17}
Language: plain_text
Name: Field values needed for graphqlconfig file
Description:
You will need field values (e.g. Project Name, URL, SchemaPath) to configure the graphqlconfig file.
The graphqlconfig file has placeholders containing default values that must be replaced with values obtained from your Fluent Account.
Check the following table for placeholder values to be inserted:
Placeholder | Values to be inserted |
<YOUR_PROJECT_NAME> | Use your Fluent Account ID e.g. FCTRAINAU543 |
src/main/graphql/<YOUR_PROJECT_GROUP_PATH>/schema.json | Use the path to the folder which contains the Schema.json file. For our example we will use com.training as it has Schema.json |
https://<YOUR_FLUENT_ACCOUNT_ID>.sandbox.api.fluentretail.com/graphql | Use your Fluent Account ID e.g. FCTRAINAU543 |
⚠️ You may have to restart your IntelliJ to work on the validated GraphQL environment
💡 Below you will see an example of a validated graphqlconfig file.
Remember to use your Fluent account details in place of the placeholder information.
This video illustrates how to:
✅ Create a GraphQLConfig file
✅ Replace the content of generated GraphQLConfig file with the Fluent code
✅ How to fill the placeholders with your Fluent Account values
So far, you've created and validated the graphqlconfig file for your Plugin Project. Now we will complete the steps (steps 1 to 3 below) to run a GraphQL query and generate a Java class from Apollo framework.
You can define a GraphQL query that can be used in a Rule. For example, if a Rule needs to evaluate an Order's total price, the Rule needs to retrieve this field via a GraphQL query. In this step, you will modify the existing GraphQL GetOrderById query:
1query GetOrderById($id: ID!) {
2 orderById(id: $id) {
3 id
4 ref
5 type
6 status
7 totalPrice
8 attributes {
9 name
10 type
11 value
12 }
13 }
14}
Language: plain_text
Name: Modified GetOrderById Query
Description:
Modified GetOrderById GQL query to evaluate total price of an Order.
⚠️ You can create new GraphQL queries or mutations in your plugin project's src/main/graphql/com.training/ (under mutation/queries subfolder)
Follow the instructions below to run the query. Upon completing the steps, you should see the GetOrderById query data including the Order's total price in the query result window.
Perform a Maven build to let the Apollo GraphQL maven plugin generate a Java class based on the above query.
This video illustrates how to:
✅ Create and run a query
✅ Generate the GraphQL classes
Copyright © 2025 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.