Search⌘ K

Field Arguments

Explore how to add field arguments to GraphQL schemas in Absinthe, allowing users to provide input parameters that tailor query results. Understand how to define arguments, implement resolvers that handle optional inputs, and refactor logic for clarity. This lesson helps you make your API queries more flexible and readable while integrating business logic effectively.

We'll cover the following...

Defining field arguments

GraphQL documents are made up of fields. The user lists the fields they would like, and the schema uses its definition of those fields to resolve the pieces of data that match. However, the system would be inflexible if it did not allow users to provide additional parameters to clarify exactly what information each field needs to find. A user requesting information about menuItems, for instance, may want to see certain menu items or a certain number of them. For this reason, GraphQL has the concept of field arguments, which are defined as “a way for users to provide input to fields that can be used to parameterize their queries.”

Let’s look at our example application and see how we can extend our Absinthe schema ...