node-appwrite
Version:
Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API
73 lines (70 loc) • 1.67 kB
JavaScript
var client = require('../client');
class Graphql {
constructor(client) {
this.client = client;
}
/**
* GraphQL endpoint
*
* Execute a GraphQL mutation.
*
* @param {object} query
* @throws {AppwriteException}
* @returns {Promise<{}>}
*/
async query(query) {
if (typeof query === "undefined") {
throw new client.AppwriteException('Missing required parameter: "query"');
}
const apiPath = "/graphql";
const payload = {};
if (typeof query !== "undefined") {
payload["query"] = query;
}
const uri = new URL(this.client.config.endpoint + apiPath);
const apiHeaders = {
"x-sdk-graphql": "true",
"content-type": "application/json"
};
return await this.client.call(
"post",
uri,
apiHeaders,
payload
);
}
/**
* GraphQL endpoint
*
* Execute a GraphQL mutation.
*
* @param {object} query
* @throws {AppwriteException}
* @returns {Promise<{}>}
*/
async mutation(query) {
if (typeof query === "undefined") {
throw new client.AppwriteException('Missing required parameter: "query"');
}
const apiPath = "/graphql/mutation";
const payload = {};
if (typeof query !== "undefined") {
payload["query"] = query;
}
const uri = new URL(this.client.config.endpoint + apiPath);
const apiHeaders = {
"x-sdk-graphql": "true",
"content-type": "application/json"
};
return await this.client.call(
"post",
uri,
apiHeaders,
payload
);
}
}
exports.Graphql = Graphql;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=graphql.js.map
;