Skip to content

Commit

Permalink
Merge branch 'releases/august' into feat/devtools-port-change-ability
Browse files Browse the repository at this point in the history
  • Loading branch information
BatuhanW authored Jul 25, 2024
2 parents 606201e + 466a68c commit 6c3535a
Show file tree
Hide file tree
Showing 10 changed files with 499 additions and 134 deletions.
9 changes: 9 additions & 0 deletions .changeset/fast-hounds-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@refinedev/mui": patch
---

fix(use-data-grid): incompatible types when using data-grid-pro

useDataGrid overide DataGridPropsType onFilterModelChange.

[Fixes #5997](https://github.com/refinedev/refine/issues/5997)
7 changes: 7 additions & 0 deletions .changeset/pretty-gifts-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/nestjs-query": patch
---

Custom requests now correctly support GET requests and makes uses of custom URL and headers.

Resolves #6112
9 changes: 9 additions & 0 deletions .changeset/pretty-snails-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@refinedev/devtools-internal": patch
---

fix(devtools-internal): fix noop return on hooks for production builds

Currently, `@refinedev/devtools-internal` returns noop function when bundled for production, yet the notation is not correctly interpreted by some bundlers. This PR fixes the issue by moving the empty return and noop functions to a separate definition.

[Resolves #6030](https://github.com/refinedev/refine/issues/6030)
7 changes: 7 additions & 0 deletions .changeset/spotty-rocks-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/core": patch
---

chore(devtools): bump internal devtools dependency

Bump `@refinedev/devtools-internal` version.
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,8 @@ When the user filters a column, this function is called with the new filter mode
{...dataGridProps}
columns={columns}
autoHeight
onFilterModelChange={(model, details) => {
dataGridProps.onFilterModelChange(model, details);
onFilterModelChange={(model) => {
dataGridProps.onFilterModelChange(model);
// do something else
}}
/>
Expand Down
7 changes: 4 additions & 3 deletions packages/devtools-internal/src/use-query-subscription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import type { QueryClient } from "@tanstack/react-query";
import React, { useContext } from "react";
import { createQueryListener, createMutationListener } from "./listeners";

const empty = {};
const noop = () => empty;

export const useQuerySubscription =
__DEV_CONDITION__ !== "development"
? () => {
return {};
}
? noop
: (queryClient: QueryClient) => {
const { ws } = useContext(DevToolsContext);
const queryCacheSubscription = React.useRef<() => void>();
Expand Down
6 changes: 5 additions & 1 deletion packages/mui/src/hooks/useDataGrid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ import {
transformSortModelToCrudSorting,
} from "@definitions";

type DataGridPropsOverride = Omit<DataGridProps, "onFilterModelChange"> & {
onFilterModelChange: (model: GridFilterModel) => void;
};

type DataGridPropsType = Required<
Pick<
DataGridProps,
DataGridPropsOverride,
| "rows"
| "loading"
| "rowCount"
Expand Down
40 changes: 25 additions & 15 deletions packages/nestjs-query/src/dataProvider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { BaseRecord, DataProvider, LogicalFilter } from "@refinedev/core";
import camelcase from "camelcase";
import * as gql from "gql-query-builder";
import type VariableOptions from "gql-query-builder/build/VariableOptions";
import type { GraphQLClient } from "graphql-request";
import { GraphQLClient } from "graphql-request";
import gqlTag from "graphql-tag";
import { singular } from "pluralize";

Expand Down Expand Up @@ -419,30 +419,37 @@ const dataProvider = (client: GraphQLClient): Required<DataProvider> => {
return (client as any).url; // url field in GraphQLClient is private
},
custom: async ({ url, method, headers, meta }) => {
if (url) {
client.setEndpoint(url);
}
const SUPPORTED_METHODS = ["get", "post"];
const requestUrl = url || (client as any).url;

if (headers) {
client.setHeaders(headers);
if (!SUPPORTED_METHODS.some((it) => it === method)) {
throw Error(`GraphQL does not support ${method} method.`);
}

const validMethod = method as "get" | "post";

const _client = new GraphQLClient(requestUrl, {
...client.requestConfig,
method: validMethod,
headers: { ...client.requestConfig.headers, ...headers },
});

const gqlOperation = meta?.gqlMutation ?? meta?.gqlQuery;

if (gqlOperation) {
const response: any = await client.request(
gqlOperation,
meta?.variables ?? {},
);
const response: any = await _client.request<BaseRecord>({
document: gqlOperation,
variables: meta?.variables,
});

return { data: response };
}

if (meta?.rawQuery) {
const response = await client.request<BaseRecord>(
meta.rawQuery,
meta.variables,
);
const response = await _client.request<BaseRecord>({
document: meta.rawQuery,
variables: meta.variables,
});

return { data: response };
}
Expand Down Expand Up @@ -472,7 +479,10 @@ const dataProvider = (client: GraphQLClient): Required<DataProvider> => {
variables = gqlMutation.variables;
}

const response = await client.request<BaseRecord>(query, variables);
const response = await _client.request<BaseRecord>({
document: query,
variables,
});

return {
data: response[meta.operation],
Expand Down
Loading

0 comments on commit 6c3535a

Please sign in to comment.