Skip to content

Commit 1faa188

Browse files
Revert "fix(data): correct GraphQL mutation input type name format (#84)" (#98)
1 parent a8b24be commit 1faa188

2 files changed

Lines changed: 2 additions & 49 deletions

File tree

src/data/GraphQLResolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class GraphQLResolver implements DataResolver {
154154
async create<T>(model: string, input: Omit<T, 'id'>): Promise<T> {
155155
const schema = this.schema(model);
156156
const { collection } = schema;
157-
const inputType = `${this.graphPrefix}_${capitalize(collection)}Summary_CreateInput`;
157+
const inputType = `${this.graphPrefix}_${capitalize(collection)}Summary_Create_Input`;
158158
const mutationName = `${this.referenceId}_create${model}`;
159159

160160
const selectionSet = await this.selectionSetFor(schema);
@@ -174,7 +174,7 @@ export class GraphQLResolver implements DataResolver {
174174
async update<T>(model: string, id: string, input: Partial<T>): Promise<T> {
175175
const schema = this.schema(model);
176176
const { collection } = schema;
177-
const inputType = `${this.graphPrefix}_${capitalize(collection)}Summary_UpdateInput`;
177+
const inputType = `${this.graphPrefix}_${capitalize(collection)}Summary_Update_Input`;
178178
const mutationName = `${this.referenceId}_update${model}`;
179179

180180
const selectionSet = await this.selectionSetFor(schema);

tests/data/GraphQLResolver.test.ts

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,54 +13,7 @@ function mockFetch(data: unknown[] = []) {
1313
});
1414
}
1515

16-
function mockMutationFetch(mutationKey: string) {
17-
return vi.fn().mockResolvedValue({
18-
ok: true,
19-
status: 200,
20-
json: () =>
21-
Promise.resolve({
22-
data: {
23-
[mutationKey]: { workdayID: { id: '1', type: 'Thing' }, descriptor: 'T' },
24-
},
25-
}),
26-
});
27-
}
28-
2916
describe('GraphQLResolver', () => {
30-
describe('create', () => {
31-
describe('when creating a record', () => {
32-
it('uses the correct input type name in the mutation', async () => {
33-
globalThis.fetch = mockMutationFetch('app_ns1_createThing');
34-
35-
await new GraphQLResolver('app_ns1', { Thing: SCHEMA }, ENDPOINT).create('Thing', {
36-
descriptor: 'T',
37-
});
38-
39-
const body = JSON.parse(
40-
(globalThis.fetch as ReturnType<typeof vi.fn>).mock.calls[0][1].body as string
41-
);
42-
expect(body.query).toContain('$input: App_ns1_ThingsSummary_CreateInput!');
43-
});
44-
});
45-
});
46-
47-
describe('update', () => {
48-
describe('when updating a record', () => {
49-
it('uses the correct input type name in the mutation', async () => {
50-
globalThis.fetch = mockMutationFetch('app_ns1_updateThing');
51-
52-
await new GraphQLResolver('app_ns1', { Thing: SCHEMA }, ENDPOINT).update('Thing', '1', {
53-
descriptor: 'T',
54-
});
55-
56-
const body = JSON.parse(
57-
(globalThis.fetch as ReturnType<typeof vi.fn>).mock.calls[0][1].body as string
58-
);
59-
expect(body.query).toContain('$input: App_ns1_ThingsSummary_UpdateInput!');
60-
});
61-
});
62-
});
63-
6417
describe('when constructed with an explicit endpoint', () => {
6518
it('sends requests to that endpoint', async () => {
6619
globalThis.fetch = mockFetch();

0 commit comments

Comments
 (0)