Schema with Object Types and Fields
Learn how the GraphQL server and the client communicate through object types and fields.
We'll cover the following...
GraphQL object types and fields
Object types are the building blocks of GraphQL schema. They reflect available objects and fields from our server. Let’s check out our first GraphQL schema language.
-
Pizzais a GraphQL Object Type, which means that it’s a type with some fields. We’ll be dealing with object types the most. -
id,name,stock, andtoppingsare fields on thePizzatype. These are the fields that are allowed to appear in a GraphQL query that operates on thePizzatype. -
IntandStringare the built-in scalar types in GraphQL. These are types that resolve to a scalar value and can’t have sub-selections in the query. We’ll go over scalar types later. -
String!means that the field is non-nullable, meaning that the GraphQL service promises to always give us a value when we query this field. In the type language, we’ll represent this with an exclamation mark (!). -
[Topping!]!...