Starting with listing the entities that are involved in a basic to-do app, this step in the GraphQL tutorial walks you through schema design.
Task
type. Then the User
type has a username (unique identifier), name and the
tasks.
So each user can have many tasks.
@id
directive to username
which makes it the unique key & also
add @hasInverse
directive to enable the relationship between tasks and user.
We represent that in the GraphQL schema shown below:
schema.graphql
.
http://localhost:8080/graphql
. If you know
lots about GraphQL, you might want to explore the schema, queries and mutations
that were generated from the schema.
completed
field, for which we add
@search
directive to the field, as shown in the schema below:
@search
directive is added to support the native search indexes of
Dgraph.
Resubmit the updated schema -
title
field, for which we add
another @search
directive to the field, as shown in the schema below:
fulltext
search index provides the advanced search capability to perform
equality comparison as well as matching with language-specific stemming and
stopwords.
Resubmit the updated schema -