Adding Fields in GraphQL Schema

Learn adding fields in GraphQL schema.

We'll cover the following

Adding fields

We can add fields to an object type using the field macro. The macro takes an identifier atom, a type reference, an optional keyword list of attributes, and another optional block for more in-depth configuration We’ll start with the basics and add :id, :name, and :description fields to our :menu_item object in schema.ex file. We can do this in the following way:

Note: The schema file is automatically created when we make a project.

Get hands-on with 1200+ tech skills courses.