Skip to content

Commit

Permalink
feat(nestjs-query): implement getApiUrl (#5983)
Browse files Browse the repository at this point in the history
Co-authored-by: Alican Erdurmaz <alicanerdurmaz@gmail.com>
  • Loading branch information
2 people authored and BatuhanW committed Jun 4, 2024
1 parent 90930b3 commit e154d39
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changeset/thick-doors-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/nestjs-query": minor
---

feat(nestjs-query): implemented getApiUrl

resolves #5606
2 changes: 1 addition & 1 deletion packages/nestjs-query/src/dataProvider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ const dataProvider = (client: GraphQLClient): Required<DataProvider> => {
};
},
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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nestjs-query/test/gqlClient.ts
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
12 changes: 12 additions & 0 deletions packages/nestjs-query/test/useApiUrl/index.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
});

0 comments on commit e154d39

Please sign in to comment.