Scalar Types
It consist of all the primitive data types. Primitive data types are the basic building blocks for other GraphQL Types and they can store only a single value. GraphQL object type have a specific name and fields and these fields are used to resolve concrete data and they represent the leaves of the query.
Some Scalar types in GraphQL
Int - It is a 32-bit signed integer or number
Float - It is a floating point value i.e. signed double precision
String - It is a sequence of characters
Boolean - It can be either True or False
ID - It is an unique identifier that is used to fetch an object
Syntax:
Here it is a pair of name-field. “field_name” is a name and “data_type” is a field corresponds to that name.
field_name: data_type
Example:
type Person {
id: ID!
name: String!
age: Int!
}
Types in GraphQL
GraphQL is a strongly typed query language used as a manipulative language for various APIs. It is also called a query language for APIs. GraphQL also helps to describe our data. GraphQL services can run in any language In this, Types are the fundamental concepts that define various data types present in GraphQL and It is also used to define the schema using different data types. There are multiple types in GraphQL.