Class: Appwrite::Graphql

Inherits:
Service show all
Defined in:
lib/appwrite/services/graphql.rb

Instance Method Summary collapse

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.

Parameters:

  • query (Hash)

    The query or queries to execute.

Returns:

  • (Any)


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.

Parameters:

  • query (Hash)

    The query or queries to execute.

Returns:

  • (Any)


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