In this tutorial, we will explore more about using Scalars on Hypi’s low code platform.
So, here is the first question: What are scalars?
Scalar types represent primitive leaf values in a GraphQL type system. GraphQL responses take the form of a hierarchical tree. The leaves of this tree are typically GraphQL Scalar types. (May also be Enum types or null values). The Scalar fields don’t have any sub-fields – they are the leaves of the query.
The second question is, “How to use Scalars in a schema design?”
We are building a Social Media Platform and we want to determine the fields of a Post object. Here is our sample Schema.
type Post {
postedby: Account @computed(query: "hypi.id = '${self.hypi.createdBy}'")
date: DateTime
text: String
likecount: Int @computedCount(field: "likedby")
likedby: [Account!]
comments: [Post!]
rating: Float
share: Json
postuuid: UUID
gppost: Boolean
tagFriends: [String]
}
The above Post object has used certain built-in scalar types from GraphQL like String, Int, Float, Boolean, etc. It supports custom scalar types like DateTime, UUID, JSON as well.