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
68 lines (66 loc) • 1.61 kB
JavaScript
import { AppwriteException } from '../client.mjs';
// src/services/graphql.ts
var Graphql = class {
constructor(client) {
this.client = client;
}
/**
* Execute a GraphQL mutation.
*
* @param {object} query
* @throws {AppwriteException}
* @returns {Promise<{}>}
*/
query(query) {
if (typeof query === "undefined") {
throw new 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 this.client.call(
"post",
uri,
apiHeaders,
payload
);
}
/**
* Execute a GraphQL mutation.
*
* @param {object} query
* @throws {AppwriteException}
* @returns {Promise<{}>}
*/
mutation(query) {
if (typeof query === "undefined") {
throw new 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 this.client.call(
"post",
uri,
apiHeaders,
payload
);
}
};
export { Graphql };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=graphql.mjs.map