View Source Bonfire.API.GraphQL.QueryHelper (Bonfire v0.9.10-classic-beta.169)
Helpful functions for preparing to query or test Absinthe applications.
These functions make it trivially easy to generate very large, comprehensive queries for our types in Absinthe that will resolve every field in that type (and any number of subtypes as well to a given level of depth)
Adapted from https://github.com/devonestes/assertions (MIT license)
Summary
Functions
Returns a document containing the fields in a type and any sub-types down to a limited depth of
nesting (default 3
).
Returns all fields in a type and any sub-types down to a limited depth of nesting (default 3
).
Functions
@spec document_for(module(), atom(), non_neg_integer(), Keyword.t()) :: String.t()
Returns a document containing the fields in a type and any sub-types down to a limited depth of
nesting (default 3
).
This is helpful for generating a document to use for testing your GraphQL API. This function will always return all fields in the given type, ensuring that there aren't any accidental fields with resolver functions that aren't tested in at least some fashion.
Example
iex> document_for(:user, 2)
```
name
age
posts {
title
subtitle
}
comments {
body
}
```
@spec fields_for(module(), atom(), non_neg_integer()) :: [fields] | atom() when fields: atom() | {atom(), [fields]}
Returns all fields in a type and any sub-types down to a limited depth of nesting (default 3
).
This is helpful for converting a struct or map into an expected response that is a bare map and which can be used in some of the other assertions below.
maybe_debug_api(q, obj, debug, msg \\ "The below GraphQL query had some errors in the response")
View Source@spec query_with_id(module(), atom(), non_neg_integer(), Keyword.t()) :: String.t()