Providing Field Argument Values

There are two ways that a GraphQL user can provide argument values for an argument: as document literals, and as variables.

Using Literals

Using document literals, values are embedded directly inside the GraphQL document. It’s a straightforward approach that works well for static documents. Here’s a query that uses a document literal for the matching argument that we’ve added to retrieve menu items whose names match "reu":

​ {
» menuItems(matching: ​"reu"​) {
​  name
​  }
​ }

Argument values are given after the argument name and a colon (:), and the literal for a :string argument is enclosed in double quotes ("). Let’s use this query in a new test, just as we did in ​Testing Our Query​ ...

Get Craft GraphQL APIs in Elixir with Absinthe now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.