-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathgraphql.dart
More file actions
59 lines (48 loc) · 1.17 KB
/
graphql.dart
File metadata and controls
59 lines (48 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
part of appwrite;
/// The GraphQL API allows you to query and mutate your Appwrite server using
/// GraphQL.
class Graphql extends Service {
Graphql(super.client);
/// GraphQL Endpoint
///
/// Execute a GraphQL mutation.
///
Future query({required Map query}) async {
const String path = '/graphql';
final Map<String, dynamic> params = {
'query': query,
};
final Map<String, String> headers = {
'x-sdk-graphql': 'true',
'content-type': 'application/json',
};
final res = await client.call(CallParams(
HttpMethod.post,
path,
params: params,
headers: headers,
));
return res.data;
}
/// GraphQL Endpoint
///
/// Execute a GraphQL mutation.
///
Future mutation({required Map query}) async {
const String path = '/graphql/mutation';
final Map<String, dynamic> params = {
'query': query,
};
final Map<String, String> headers = {
'x-sdk-graphql': 'true',
'content-type': 'application/json',
};
final res = await client.call(CallParams(
HttpMethod.post,
path,
params: params,
headers: headers,
));
return res.data;
}
}