Show me how
-
US cloud (non-EU host): Exchange (US)
-
EU cloud (EU host): Exchange (EU)
This tutorial guides you through creating a Mule application from scratch, implementing a GraphQL API that you publish to Exchange.
Complete these procedures:
Set up your MuleSoft environment. See Getting Started with Anypoint Code Builder for more information.
Download the Books API GraphQL schema.
To implement a GraphQL API, the API must first be manually published to Exchange:
Navigate to Anypoint Exchange.
US cloud (non-EU host): Exchange (US)
EU cloud (EU host): Exchange (EU)
Click Publish new asset.
For Name, type books-api
.
For Asset types, select GraphQL API.
For Method, select Upload a GraphQL API Schema:
For File upload, click Choose file and browse for your books-api.graphql
schema file.
For Lifecycle state, select Stable.
Click Publish.
Navigate to Anypoint Code Builder.
Open the Command Palette.
Use the keyboard shortcuts:
Mac: Cmd+Shift+p
Windows: Ctrl+Shift+p
In the desktop IDE, select View > Command Palette.
In the cloud IDE, click the (menu) icon, and select View > Command Palette.
Provide this command:
MuleSoft: Implement an API Specification
Select the command.
Configure your project using the following values:
1 | Project Name: books-implementation |
2 | Project Location: click Browse, and then select your home directory. |
3 | Search for an API specification published in Exchange to implement. Start typing books and press Return to display a list of possible results. Click Add Asset for the books-api asset:
|
Click Create Project.
Anypoint Code Builder scaffolds your GraphQL API and creates an empty flow for each type in your Books API GraphQL schema.
GraphQL Schema | Mule Flow |
---|---|
|
|
Anypoint Code Builder also creates a <graphql-router:data-fetcher>
as sources for each of your Mule flows. See Mapping a GraphQL API to Your Data Sources for more information about data fetchers.
Proceed to Test Your GraphQL Implementation to run your application in Anypoint Code Builder and post GraphQL queries to your endpoint.