flutter_graphql_client 0.1.20 flutter_graphql_client: ^0.1.20 copied to clipboard
Client to POST to GraphQL server
flutter_graphql_client #
flutter_graphql_client
is an open source project — it's one among many other shared libraries that make up the wider ecosystem of software made and open sourced by Savannah Informatics Limited
.
A shared library for BeWell-Consumer
and BeWell-Professional
that is responsible for exposing graphql_client and helper methods for use in the various apps.
This package implements functions to make API calls. This blends both GRAPHQL and REST. Since graphql make this bulk of this package, the name of the package favours.
Installation Instructions #
Use this package as a library by depending on it
Run this command:
- With Flutter:
$ flutter pub add flutter_graphql_client
This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):
dependencies:
flutter_graphql_client: ^0.1.20
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
Lastly:
Import it like so:
import 'package:flutter_graphql_client/graph_client.dart';
How to use this package #
Making GRAPHQL calls #
final dynamic data = await SimpleCall.callAPI(
querystring: 'valid-query-string' ,
variables: <String, dynamic>{'pay':'load'},
graphClient: silGraphQlClientInstance ,
)
Making REST calls #
GET
final dynamic data = await SimpleCall.callRestAPI(
endpoint: 'http://example.com/test' ,
method: 'GET',
graphClient: silGraphQlClientInstance ,
)
POST
final dynamic data = await SimpleCall.callRestAPI(
endpoint: 'http://example.com/test' ,
method: 'POST',
variables: <String, dynamic>{'pay':'load'},
graphClient: silGraphQlClientInstance ,
)