-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathgraphql.py
More file actions
40 lines (28 loc) · 1.03 KB
/
graphql.py
File metadata and controls
40 lines (28 loc) · 1.03 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
from ..service import Service
from typing import List
from ..exception import AppwriteException
class Graphql(Service):
def __init__(self, client):
super(Graphql, self).__init__(client)
def query(self, query: dict):
"""GraphQL endpoint"""
api_path = '/graphql'
api_params = {}
if query is None:
raise AppwriteException('Missing required parameter: "query"')
api_params['query'] = query
return self.client.call('post', api_path, {
'x-sdk-graphql': 'true',
'content-type': 'application/json',
}, api_params)
def mutation(self, query: dict):
"""GraphQL endpoint"""
api_path = '/graphql/mutation'
api_params = {}
if query is None:
raise AppwriteException('Missing required parameter: "query"')
api_params['query'] = query
return self.client.call('post', api_path, {
'x-sdk-graphql': 'true',
'content-type': 'application/json',
}, api_params)