mirror of
https://github.com/appwrite/sdk-for-flutter.git
synced 2026-04-07 19:27:41 +00:00
46 lines
1.2 KiB
Dart
46 lines
1.2 KiB
Dart
part of '../appwrite.dart';
|
|
|
|
/// The GraphQL API allows you to query and mutate your Appwrite server using
|
|
/// GraphQL.
|
|
class Graphql extends Service {
|
|
/// Initializes a [Graphql] service
|
|
Graphql(super.client);
|
|
|
|
/// Execute a GraphQL mutation.
|
|
Future query({required Map query}) async {
|
|
const String apiPath = '/graphql';
|
|
|
|
final Map<String, dynamic> apiParams = {
|
|
'query': query,
|
|
|
|
};
|
|
|
|
final Map<String, String> apiHeaders = {
|
|
'x-sdk-graphql': 'true', 'content-type': 'application/json',
|
|
};
|
|
|
|
final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders);
|
|
|
|
return res.data;
|
|
|
|
}
|
|
|
|
/// Execute a GraphQL mutation.
|
|
Future mutation({required Map query}) async {
|
|
const String apiPath = '/graphql/mutation';
|
|
|
|
final Map<String, dynamic> apiParams = {
|
|
'query': query,
|
|
|
|
};
|
|
|
|
final Map<String, String> apiHeaders = {
|
|
'x-sdk-graphql': 'true', 'content-type': 'application/json',
|
|
};
|
|
|
|
final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders);
|
|
|
|
return res.data;
|
|
|
|
}
|
|
} |