API SDK GraphQL
For all the GraphQL operations, there is a folder named graphql_operation
which contains all the queries. graphql_handler.dart
is used to handle this and it contains all the functions to query or mutate a client.
In api_constants.dart
, set the GraphQLClient with _httpLink
and _authLink
. Next, in the main.dart
file for API SDK, call a function to get the data. For example, there is a function for accessing Github repositories:
static fetchGithubRepoGraphQl(numOfRepositories) async {
final GraphqlQlHandler githubRepository =
GraphqlQlHandler(client: client());
final response = await githubRepository.getRepositories(numOfRepositories);
return response;
}
The client()
comes from api_constants.dart
.
Use the following to call the function:
ApiSdk.fetchGithubRepoGraphQl(10);