Previously, you determined the cost of running your query. As the provider of the GraphQL API, you can now create a new Product and a Plan based on cost and GraphQL rating limits.
You are now ready to create the Product for your GraphQL API and specify new Plans based on cost and rating limits. Let’s get started:
- Click on the Develop link in the top-left corner and get ready to Add a new Product:

Figure 9.21 – Using the Develop link to return to the main menu
- Click Add and select Product.
- Provide the new Product with a name, choose your GraphQL API, and click Next.
- Choose your API and click Next.
- Click Add to add a new Plan. A default Plan name will be generated. Provide a new name for the Plan and continue until you’re finished.
- Choose the Publish, Visibility, and Subscribability options and click Next.
- On the Summary page, click Done.
- Open your new Product and click on Plans to choose your newly created Plan.
- Click on the three dots next to your Plan and select Edit.
- Scroll down until you find GraphQL rate limits. This is where you will choose the cost amount by unit by using various cost factors:

Figure 9.21 – Setting rate limits for your GraphQL API
This panel shows the default values. Unless you want unlimited requests, you should uncheck Unlimited and apply the costs per unit. You can adjust the values as appropriate based on the Query costs you observed previously.
Another way to reduce costs and reduce security risks is to remove fields from GraphQL schema. Next, you will learn how simple it is to do that.
Removing fields from GraphQL
Since you know that the GraphQL fields are developed on backend systems by developers, you might find out that some fields that are presented may not be allowed due to compliance and security reasons. An example would be social security numbers or certain patient history information. This poses a challenge for API developers because they know they need to obfuscate the fields in some way. API Connect provides you with a simple way to ensure that access to fields aren’t allowed to the consumers. You can do this by removing the fields in GraphQL Schema.
To see how this can be accomplished, perform the following steps:
- Navigate to any GraphQL API and click on GraphQL Schema. You will see a Show/hide column where there is a gear icon next to the field. Refer to the following screenshot:

Figure 9.23 – Removing a field using Show/hide
2. By clicking on the gear icon, you can remove the field from the fields presented to the API developer:

Figure 9.24 – The Show/hide popup
You can toggle this on or off to show the field/object in the schema. When you choose to hide, the field/object will be grayed out, as shown in the following screenshot:

Figure 9.25 – Hiding the field/object in GraphQL
3. After you click Next, you are allowed to change your mind as you are presented with a Summary panel that shows what you have changed. You can cancel or go back to make modifications or you can click Done to complete the removal process.
The results of a removal show a grayed-out object. In the following screenshot, you can see that AddressSchema was hidden:

Figure 9.26 – Results of hiding an object in a schema
Of course, you can reverse your decision by clicking on the gear icon again and turning Show back on. This is a very simple and easy way to show and hide objects/fields within your GraphQL schema.
That was a considerable amount to learn but you should have a good understanding of GraphQL APIs and how to best find the cost associated with them. Congratulations!
Summary
In this chapter, you were introduced to GraphQL and how to look at it holistically. You learned how the graph is created and what comprises the GraphQL server from a provider viewpoint.
You learned about queries, resolvers, and mutations, as well as how each type field can have an impact on costs and performance.
Developing a GraphQL API follows similar practices to other REST APIs but there were a few wrinkles in how you look at developing a Product plan due to cost factors. You learned that those cost factors provide you with details on how to set up the rating limits in your plan. Adjusting weights at the type level or field level will help determine the cost of your GraphQL API. You also learned how to remove fields from the schema to remove information that you do not wish your consumers to access.
GraphQL is not for every implementation and it certainly doesn’t replace your REST APIs, but it does provide benefits in situations where the client needs to determine what information is important for their applications. It also alleviates the providers from having multiple versions of REST services to handle differing consumer requirements.
Now that you have learned about creating APIs, next, you will learn about how API Connect allows you to package those APIs and publish them for discovery within the Developer Portal for future consumption by consumer applications. You’ll learn about that in Chapter 10, Publishing Options.