Class: Appwrite::Graphql
- Defined in:
- lib/appwrite/services/graphql.rb
Instance Method Summary collapse
-
#initialize(client) ⇒ Graphql
constructor
A new instance of Graphql.
-
#mutation(query:) ⇒ Any
Execute a GraphQL mutation.
-
#query(query:) ⇒ Any
Execute a GraphQL mutation.
Constructor Details
#initialize(client) ⇒ Graphql
Returns a new instance of Graphql.
6 7 8 |
# File 'lib/appwrite/services/graphql.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#mutation(query:) ⇒ Any
Execute a GraphQL mutation.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/appwrite/services/graphql.rb', line 45 def mutation(query:) api_path = '/graphql/mutation' if query.nil? raise Appwrite::Exception.new('Missing required parameter: "query"') end api_params = { query: query, } api_headers = { "x-sdk-graphql": 'true', "content-type": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, ) end |
#query(query:) ⇒ Any
Execute a GraphQL mutation.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/appwrite/services/graphql.rb', line 15 def query(query:) api_path = '/graphql' if query.nil? raise Appwrite::Exception.new('Missing required parameter: "query"') end api_params = { query: query, } api_headers = { "x-sdk-graphql": 'true', "content-type": 'application/json', } @client.call( method: 'POST', path: api_path, headers: api_headers, params: api_params, ) end |