From 84adce30b3f0cbdb333c262d1aa5693427bba3fc Mon Sep 17 00:00:00 2001 From: Yeldar <57894795+issa012@users.noreply.github.com> Date: Wed, 29 May 2024 11:46:59 +0500 Subject: [PATCH] feat(nestjs-query): implement getApiUrl (#5983) Co-authored-by: Alican Erdurmaz --- .changeset/thick-doors-draw.md | 7 +++++++ packages/nestjs-query/src/dataProvider/index.ts | 2 +- packages/nestjs-query/test/gqlClient.ts | 2 +- packages/nestjs-query/test/useApiUrl/index.spec.ts | 12 ++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .changeset/thick-doors-draw.md create mode 100644 packages/nestjs-query/test/useApiUrl/index.spec.ts diff --git a/.changeset/thick-doors-draw.md b/.changeset/thick-doors-draw.md new file mode 100644 index 000000000000..4b5114cf0c99 --- /dev/null +++ b/.changeset/thick-doors-draw.md @@ -0,0 +1,7 @@ +--- +"@refinedev/nestjs-query": minor +--- + +feat(nestjs-query): implemented getApiUrl + +resolves #5606 diff --git a/packages/nestjs-query/src/dataProvider/index.ts b/packages/nestjs-query/src/dataProvider/index.ts index bc1f29b4b4c2..433c7bbbdf92 100644 --- a/packages/nestjs-query/src/dataProvider/index.ts +++ b/packages/nestjs-query/src/dataProvider/index.ts @@ -416,7 +416,7 @@ const dataProvider = (client: GraphQLClient): Required => { }; }, getApiUrl: () => { - throw Error("Not implemented on refine-nestjs-query data provider."); + return (client as any).url; // url field in GraphQLClient is private }, custom: async ({ url, method, headers, meta }) => { if (url) { diff --git a/packages/nestjs-query/test/gqlClient.ts b/packages/nestjs-query/test/gqlClient.ts index efe169f9e0ed..18f16cea484b 100644 --- a/packages/nestjs-query/test/gqlClient.ts +++ b/packages/nestjs-query/test/gqlClient.ts @@ -1,7 +1,7 @@ import { GraphQLClient } from "graphql-request"; // const API_URL = "https://api.nestjs-query.refine.dev/graphql"; -const API_URL = "http://localhost:3003/graphql"; +export const API_URL = "http://localhost:3003/graphql"; const client = new GraphQLClient(API_URL); diff --git a/packages/nestjs-query/test/useApiUrl/index.spec.ts b/packages/nestjs-query/test/useApiUrl/index.spec.ts new file mode 100644 index 000000000000..1388d9df1a68 --- /dev/null +++ b/packages/nestjs-query/test/useApiUrl/index.spec.ts @@ -0,0 +1,12 @@ +import dataProvider from "../../src/index"; +import client, { API_URL } from "../gqlClient"; + +describe("getApiUrl", () => { + describe("should return API URL from client", () => { + it("correct response with getApiUrl", async () => { + const apiURL = dataProvider(client).getApiUrl(); + + expect(apiURL).toEqual(API_URL); + }); + }); +});