Queries generated for a GraphQL type allow you to generate a single list of objects for a type. You can also query a list of objects using GraphQL.
title, text and datePublished for a post with id 0x1.
get queries is also easy. For
example, this is how you would fetch the authors for a post and their friends.
id 0x1 and their
posts about GraphQL.
@id directive applied to it, you can also
fetch objects using that.
For example, given the following schema, the query below fetches a user’s name
and age by userID (which has the @id directive):
Schema:
title, text and datePublished for all posts:
id:
@search directive
to the field that’s used to filter the results.
For example, if you wanted to query events between two dates, or events that
fall within a certain radius of a point, you could have an Event schema, as
follows:
and keyword to show results with
multiple filters applied. In the query below, we fetch posts that have GraphQL
in their title and have a score > 100.
This example assumes that the Post type has a @search directive applied to
the title field and the score field.
Lee and with their completed posts that have a score greater than 10:
betweenbetween keyword.
between.between filter, you could fetch records for students who are between
10 and 20 years of age:
Query:
ba and hz:
Query:
inin keyword. This keyword can find matches for fields with the @id
directive applied. The in filter is supported for all data types such as
string, enum, Int, Int64, Float, and DateTime.
For example, let’s say that your schema defines a State type that has the
@id directive applied to the code field:
in keyword, you can query for a list of states that have the postal
code WA or VA using the following query:
hashas keyword. The has keyword can only check whether a field
returns a non-null value, not for specific field values.
For example, your schema might define a Student type that has basic
information about each student such as their ID number, age, name, and email
address:
name, run the following query:
Student objects where both name and email fields are
non-null.