Last active
May 12, 2021 22:40
-
-
Save ramyak-mehra/b345cf9f67092fe2b06eee2a7198784e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Future<FetchPokemons$Query> _fetchArtemisClient(ArtemisClient client) async { | |
| final pokemonsQuery = | |
| FetchPokemonsQuery(variables: FetchPokemonsArguments(quantity: 15)); | |
| final result = await client.execute(pokemonsQuery); | |
| if (result.hasErrors) { | |
| throw Exception(result.errors); | |
| } | |
| return result.data!; | |
| } | |
| //If you are using something like graphql for client you can do something like this. | |
| Future<FetchPokemons$Query> _fetchGraphqlClient(GraphQLClient client) async { | |
| final pokemonsQuery = | |
| FetchPokemonsQuery(variables: FetchPokemonsArguments(quantity: 20)); | |
| final queryOptions = QueryOptions( | |
| document: pokemonsQuery.document, | |
| variables: pokemonsQuery.variables.toJson(), | |
| fetchPolicy: FetchPolicy.cacheAndNetwork); | |
| final result = await client.query(queryOptions); | |
| if (result.hasException) { | |
| throw result.exception!; | |
| } | |
| return FetchPokemons$Query.fromJson(result.data!); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment