Skip to content

Commit c62a8aa

Browse files
Revert "fix(hasura): meta.gqlVariables passed to deleteMany Hasura data provider" (#6791)
1 parent 135dfb7 commit c62a8aa

File tree

4 files changed

+3
-228
lines changed

4 files changed

+3
-228
lines changed

.changeset/sweet-games-juggle.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/hasura/src/dataProvider/index.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -509,26 +509,13 @@ const dataProvider = (
509509
: camelcase(`delete_${operation}`);
510510

511511
if (meta?.gqlMutation) {
512-
const hasuraFilters = mergeHasuraFilters(
513-
{
512+
const response = await client.request<BaseRecord>(meta?.gqlMutation, {
513+
where: {
514514
id: {
515515
_in: ids,
516516
},
517517
},
518-
meta?.gqlVariables?.where,
519-
);
520-
521-
const variables = {
522-
...(meta.gqlVariables && meta.gqlVariables),
523-
...(hasuraFilters && {
524-
where: hasuraFilters,
525-
}),
526-
};
527-
528-
const response = await client.request<BaseRecord>(
529-
meta?.gqlMutation,
530-
variables,
531-
);
518+
});
532519

533520
return {
534521
data: response[deleteOperation]["returning"],

packages/hasura/test/deleteMany/index.mock.ts

Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -511,135 +511,3 @@ nock("https://ruling-redbird-23.hasura.app:443", { encodedQueryParams: true })
511511
"84374d0c4fe2733a-BUD",
512512
],
513513
);
514-
515-
// Mock for DeleteManyPosts with includeTitle=true from gqlVariables
516-
nock("https://flowing-mammal-24.hasura.app:443", { encodedQueryParams: true })
517-
.post("/v1/graphql", {
518-
query:
519-
"mutation DeleteManyPosts($where: posts_bool_exp!, $includeTitle: Boolean = false) {\n delete_posts(where: $where) {\n returning {\n id\n title @include(if: $includeTitle)\n }\n }\n}\n",
520-
variables: {
521-
where: {
522-
id: {
523-
_in: [
524-
"c5d4e3f2-a1b0-9c8d-7e6f-5a4b3c2d1e0f",
525-
"f0e1d2c3-b4a5-6789-8f7e-6d5c4b3a2f1e",
526-
],
527-
},
528-
},
529-
includeTitle: true,
530-
},
531-
operationName: "DeleteManyPosts",
532-
})
533-
.reply(
534-
200,
535-
{
536-
data: {
537-
delete_posts: {
538-
returning: [
539-
{
540-
id: "c5d4e3f2-a1b0-9c8d-7e6f-5a4b3c2d1e0f",
541-
title: "Aenean ultricies non libero sit amet pellentesque",
542-
},
543-
{
544-
id: "f0e1d2c3-b4a5-6789-8f7e-6d5c4b3a2f1e",
545-
title: "Etiam tincidunt ex ut auctor faucibus",
546-
},
547-
],
548-
},
549-
},
550-
},
551-
[
552-
"Date",
553-
"Wed, 10 Jan 2024 19:24:37 GMT",
554-
"Content-Type",
555-
"application/json; charset=utf-8",
556-
"Content-Length",
557-
"244",
558-
"Connection",
559-
"close",
560-
"x-request-id",
561-
"7d98c24a10b32a6e7c1f5d9b8e4a2c1d",
562-
"CF-Cache-Status",
563-
"DYNAMIC",
564-
"Content-Security-Policy",
565-
"upgrade-insecure-requests",
566-
"Referrer-Policy",
567-
"strict-origin-when-cross-origin",
568-
"Strict-Transport-Security",
569-
"max-age=31536000; includeSubDomains",
570-
"X-Content-Type-Options",
571-
"nosniff",
572-
"X-Frame-Options",
573-
"SAMEORIGIN",
574-
"X-XSS-Protection",
575-
"0",
576-
"Server",
577-
"cloudflare",
578-
"CF-RAY",
579-
"84374d119bef684c-BUD",
580-
],
581-
);
582-
583-
nock("https://flowing-mammal-24.hasura.app:443", { encodedQueryParams: true })
584-
.post("/v1/graphql", {
585-
query:
586-
"mutation DeleteManyPosts($where: posts_bool_exp!, $includeTitle: Boolean = false) {\n delete_posts(where: $where) {\n returning {\n id\n title @include(if: $includeTitle)\n }\n }\n}\n",
587-
variables: {
588-
where: {
589-
id: {
590-
_in: [
591-
"d3c2b1a0-f9e8-7d6c-5b4a-3f2e1d0c9b8a",
592-
"a9b8c7d6-e5f4-3210-2f1e-0d9c8b7a6f5e",
593-
],
594-
},
595-
},
596-
},
597-
operationName: "DeleteManyPosts",
598-
})
599-
.reply(
600-
200,
601-
{
602-
data: {
603-
delete_posts: {
604-
returning: [
605-
{
606-
id: "d3c2b1a0-f9e8-7d6c-5b4a-3f2e1d0c9b8a",
607-
},
608-
{
609-
id: "a9b8c7d6-e5f4-3210-2f1e-0d9c8b7a6f5e",
610-
},
611-
],
612-
},
613-
},
614-
},
615-
[
616-
"Date",
617-
"Wed, 10 Jan 2024 19:24:38 GMT",
618-
"Content-Type",
619-
"application/json; charset=utf-8",
620-
"Content-Length",
621-
"136",
622-
"Connection",
623-
"close",
624-
"x-request-id",
625-
"3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d",
626-
"CF-Cache-Status",
627-
"DYNAMIC",
628-
"Content-Security-Policy",
629-
"upgrade-insecure-requests",
630-
"Referrer-Policy",
631-
"strict-origin-when-cross-origin",
632-
"Strict-Transport-Security",
633-
"max-age=31536000; includeSubDomains",
634-
"X-Content-Type-Options",
635-
"nosniff",
636-
"X-Frame-Options",
637-
"SAMEORIGIN",
638-
"X-XSS-Protection",
639-
"0",
640-
"Server",
641-
"cloudflare",
642-
"CF-RAY",
643-
"84374d161b7f733a-BUD",
644-
],
645-
);

packages/hasura/test/deleteMany/index.spec.ts

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -154,79 +154,4 @@ describe("with gqlMutation", () => {
154154
expect(data[0].id).toEqual(ids[0]);
155155
expect(data[1].id).toEqual(ids[1]);
156156
});
157-
158-
it("correctly passes variables from meta.gqlVariables to the query", async () => {
159-
const ids = [
160-
"c5d4e3f2-a1b0-9c8d-7e6f-5a4b3c2d1e0f",
161-
"f0e1d2c3-b4a5-6789-8f7e-6d5c4b3a2f1e",
162-
];
163-
164-
const client = createClient("hasura-default");
165-
const { data } = await dataProvider(client, {
166-
namingConvention: "hasura-default",
167-
}).deleteMany!({
168-
resource: "posts",
169-
ids,
170-
meta: {
171-
gqlMutation: gql`
172-
mutation DeleteManyPosts(
173-
$where: posts_bool_exp!,
174-
$includeTitle: Boolean = false
175-
) {
176-
delete_posts(where: $where) {
177-
returning {
178-
id
179-
title @include(if: $includeTitle)
180-
}
181-
}
182-
}
183-
`,
184-
gqlVariables: {
185-
includeTitle: true,
186-
},
187-
},
188-
});
189-
190-
expect(data[0].id).toEqual(ids[0]);
191-
expect(data[0].title).toEqual(
192-
"Aenean ultricies non libero sit amet pellentesque",
193-
);
194-
expect(data[1].id).toEqual(ids[1]);
195-
expect(data[1].title).toEqual("Etiam tincidunt ex ut auctor faucibus");
196-
});
197-
198-
it("doesn't pass extra variables to the query without meta.gqlVariables", async () => {
199-
const ids = [
200-
"d3c2b1a0-f9e8-7d6c-5b4a-3f2e1d0c9b8a",
201-
"a9b8c7d6-e5f4-3210-2f1e-0d9c8b7a6f5e",
202-
];
203-
204-
const client = createClient("hasura-default");
205-
const { data } = await dataProvider(client, {
206-
namingConvention: "hasura-default",
207-
}).deleteMany!({
208-
resource: "posts",
209-
ids,
210-
meta: {
211-
gqlMutation: gql`
212-
mutation DeleteManyPosts(
213-
$where: posts_bool_exp!,
214-
$includeTitle: Boolean = false
215-
) {
216-
delete_posts(where: $where) {
217-
returning {
218-
id
219-
title @include(if: $includeTitle)
220-
}
221-
}
222-
}
223-
`,
224-
},
225-
});
226-
227-
expect(data[0].id).toEqual(ids[0]);
228-
expect(data[0].title).toBeUndefined();
229-
expect(data[1].id).toEqual(ids[1]);
230-
expect(data[1].title).toBeUndefined();
231-
});
232157
});

0 commit comments

Comments
 (0)