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 51fbfda0ee7a..02ef100e6a25 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); + }); + }); +});