Executing a GraphQL Query with Ferry is as easy as:
- Creating an instance of the generated request class for your Query.
Client.request()with your request.
- Listen to the returned Stream.
Creating a Request
For example, let's say we've saved the following
Reviews Query to a file named
Running the Ferry generator will create a
reviews.req.gql.dart file with a Class named
GReviewsReq. We can instantiate it like so:
Notice how we can chain-assign nested values. Ferry's generated classes are based on
built_value which uses the Builder Pattern.
Check out this post for more information on
built_value classes and how to use them.
Listening to the Request Stream
Now, all we need to do is listen to the