Skip to content

Commit

Permalink
feat(chore): add graphql support
Browse files Browse the repository at this point in the history
Co-Authored-By: Conrawl Rogers <[email protected]>
  • Loading branch information
Intevel and Diizzayy committed Apr 23, 2022
1 parent 6fc2981 commit 358bbf6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/runtime/composables/useDirectusGraphQL.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useDirectusUrl } from "./useDirectusUrl";
import type { FetchError, FetchOptions } from "ohmyfetch";

export const useDirectusGraphQL = (query: any, variables?: object) => {
let url = useDirectusUrl();

// strip trailing slash
url = url.replace(/\/$/, "");

return $fetch(`${url}/graphql`, {
method: "POST",
body: JSON.stringify({ query, ...(variables && { variables }) }),
});
};

0 comments on commit 358bbf6

Please sign in to comment.