From 83ae788e710c0ad53fd327b4f141f4b48cdb2249 Mon Sep 17 00:00:00 2001 From: nuriaricart Date: Wed, 13 Sep 2023 10:03:50 +0100 Subject: [PATCH] feat(graphql): add function to fetch graphql and return response J=CR-3190 --- function-connector-sources/graphql/_resource.json | 4 ++++ function-connector-sources/graphql/mod.ts | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 function-connector-sources/graphql/_resource.json create mode 100755 function-connector-sources/graphql/mod.ts diff --git a/function-connector-sources/graphql/_resource.json b/function-connector-sources/graphql/_resource.json new file mode 100644 index 0000000..9e7d14f --- /dev/null +++ b/function-connector-sources/graphql/_resource.json @@ -0,0 +1,4 @@ +{ + "$id": "graphql", + "$schema": "https://schema.yext.com/config/platform/plugin/v1" +} \ No newline at end of file diff --git a/function-connector-sources/graphql/mod.ts b/function-connector-sources/graphql/mod.ts new file mode 100755 index 0000000..06cafd5 --- /dev/null +++ b/function-connector-sources/graphql/mod.ts @@ -0,0 +1,7 @@ +export async function fetchGraphQLAPI (graphQLUrl: string) { + const graphQLResponse = await fetch(graphQLUrl).then(response => response.json()); + + const response = { data: graphQLResponse.data }; + + return JSON.stringify(response); +}