Contact Us 1-800-596-4880

Test Your GraphQL Implementation

logo cloud IDE Cloud IDE

logo desktop IDE Desktop IDE

Open Beta Release: The cloud IDE is in open beta. Any use of Anypoint Code Builder in its beta state is subject to the applicable beta services terms and conditions, available from the IDE.

With a scaffolded project, run your application locally and test the endpoints of your Mule application.

Note that because the GraphQL schema does not allow examples, Anypoint Code Builder scaffolds an empty project, so in this first run, your responses are empty.

Before You Begin

Complete these procedures:

Run Your Application

To locally deploy your Mule Application, run a debug session in Anypoint Code Builder:

  1. In Anypoint Code Builder, open the Books Implementation project.

  2. Click the (Run and Debug) icon in the activity bar, then click the Start Debugging (F5) icon.

  3. From your IDE, open the Terminal window in the console:

    • In the desktop IDE, select View > Terminal.

    • In the cloud IDE, click the (menu) icon, and select Terminal > New Terminal.

    • For either IDE: Press Ctrl and then press the backtick key (`).

  4. In the IDE’s terminal, use the curl command, and create a POST request to the local address, adding the /graphql path: http://localhost:8081/graphql:

    curl --request POST \
    --location 'http://localhost:8081/graphql' \
    --header 'Content-Type: application/json' \
    --data '{
        "query": "query bookById($id: ID) {bookById(id: $id){ id name pageCount author{ id firstName lastName}}}",
        "variables": {
            "id": 1
        }
    }'

    For more information about using the curl command in the terminal, see Trigger a flow.

  5. Send the curl request.

    Anypoint Code Builder returns an empty field for the book:

    {
        "data": {
            "bookById": null
        }
    }

    Other queries you can try for your endpoint are:

    • Query books:

      query books {
      	books{
      		id
      		name
      		pageCount
      		author{
      			id
      			firstName
      			lastName
      		}
      	}
      }
    • Query bestSellers:

      query bestsellers {
      	bestsellers{
      		books{
      			id
      			name
      			pageCount
      			author{
      				id
      				firstName
      				lastName
      			}
      		}
      		authors{
      			id
      			firstName
      			lastName
      		}
      	}
      }

      These requests return an empty result.

  6. Proceed to Configure Responses for Your GraphQL Implementation to populate each flow with a custom response for each query.