Skip to content

Commit 45271af

Browse files
author
patrick.rehn
committed
run prettier
1 parent bf60ced commit 45271af

File tree

2 files changed

+54
-48
lines changed

2 files changed

+54
-48
lines changed

packages/plugins/response-cache/src/plugin.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export type UseResponseCacheParameter<PluginContext extends Record<string, any>
118118
* List of SchemaCoordinates in format {ObjectType}.{FieldName} which are ignored during scan for entities.
119119
* Defaults to `[]`
120120
*/
121-
ignoreIdFieldsBySchemaCoordinate?: Array<string>
121+
ignoreIdFieldsBySchemaCoordinate?: Array<string>;
122122
/**
123123
* Whether the mutation execution result should be used for invalidating resources.
124124
* Defaults to `true`
@@ -367,7 +367,11 @@ export function useResponseCache<PluginContext extends Record<string, any> = {}>
367367
const resultTypeNames = unwrapTypenames(fieldConfig.type);
368368
typePerSchemaCoordinateMap.set(schemaCoordinates, resultTypeNames);
369369

370-
if (idFields.includes(fieldName) && !idFieldByTypeName.has(typeName) && !ignoreIdFieldsBySchemaCoordinate?.includes(schemaCoordinates)) {
370+
if (
371+
idFields.includes(fieldName) &&
372+
!idFieldByTypeName.has(typeName) &&
373+
!ignoreIdFieldsBySchemaCoordinate?.includes(schemaCoordinates)
374+
) {
371375
idFieldByTypeName.set(typeName, fieldName);
372376
}
373377

packages/plugins/response-cache/test/response-cache.spec.ts

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4035,39 +4035,40 @@ it('calls enabled fn after context building', async () => {
40354035
it('id field in body is returned as is and not overwritten', async () => {
40364036
expect.assertions(1);
40374037
const queryResult = {
4038-
'id': "idString", 'header': {'id': {'fieldA': 'Tick', 'fieldB': 'Trick', 'fieldC': 'Track'}, 'someField': 'someData'}
4039-
}
4038+
id: 'idString',
4039+
header: { id: { fieldA: 'Tick', fieldB: 'Trick', fieldC: 'Track' }, someField: 'someData' },
4040+
};
40404041
const schema = makeExecutableSchema({
40414042
typeDefs: /* GraphQL */ `
40424043
type Query {
40434044
subgraphObject: SubgraphObject
4044-
},
4045+
}
40454046
type SubgraphObject {
4046-
id: String,
4047-
header: Header,
4048-
},
4047+
id: String
4048+
header: Header
4049+
}
40494050
type Header {
4050-
id: IdObject,
4051+
id: IdObject
40514052
someField: String
4052-
},
4053+
}
40534054
type IdObject {
4054-
fieldA: String,
4055-
fieldB: String,
4056-
fieldC: String,
4055+
fieldA: String
4056+
fieldB: String
4057+
fieldC: String
40574058
}
40584059
`,
40594060
resolvers: { Query: { subgraphObject: () => queryResult } },
40604061
});
40614062
const testkit = createTestkit(
4062-
[
4063-
useEngine({ ...GraphQLJS, execute: normalizedExecutor, subscribe: normalizedExecutor }),
4064-
useResponseCache({
4065-
session: () => null,
4066-
ttl:0,
4067-
ignoreIdFieldsBySchemaCoordinate:['Header.id']
4068-
}),
4069-
],
4070-
schema,
4063+
[
4064+
useEngine({ ...GraphQLJS, execute: normalizedExecutor, subscribe: normalizedExecutor }),
4065+
useResponseCache({
4066+
session: () => null,
4067+
ttl: 0,
4068+
ignoreIdFieldsBySchemaCoordinate: ['Header.id'],
4069+
}),
4070+
],
4071+
schema,
40714072
);
40724073

40734074
const document = /* GraphQL */ `
@@ -4098,42 +4099,44 @@ it('id field in body is returned as is and not overwritten', async () => {
40984099
it('id field in body overwritten and request fails', async () => {
40994100
expect.assertions(1);
41004101
const queryResult = {
4101-
'id': "idString", 'header': {'id': {'fieldA': 'Tick', 'fieldB': 'Trick', 'fieldC': 'Track'}, 'someField': 'someData'}
4102-
}
4102+
id: 'idString',
4103+
header: { id: { fieldA: 'Tick', fieldB: 'Trick', fieldC: 'Track' }, someField: 'someData' },
4104+
};
41034105
const schema = makeExecutableSchema({
41044106
typeDefs: /* GraphQL */ `
41054107
type Query {
41064108
subgraphObject: SubgraphObject
4107-
},
4109+
}
41084110
type SubgraphObject {
4109-
id: String,
4110-
header: Header!,
4111-
},
4111+
id: String
4112+
header: Header!
4113+
}
41124114
type Header {
4113-
id: IdObject!,
4115+
id: IdObject!
41144116
someField: String
4115-
},
4117+
}
41164118
type IdObject {
4117-
fieldA: String!,
4118-
fieldB: String!,
4119-
fieldC: String!,
4119+
fieldA: String!
4120+
fieldB: String!
4121+
fieldC: String!
41204122
}
41214123
`,
41224124
resolvers: { Query: { subgraphObject: () => queryResult } },
41234125
});
41244126
const testkit = createTestkit(
4125-
[
4126-
useEngine({ ...GraphQLJS, execute: normalizedExecutor, subscribe: normalizedExecutor }),
4127-
useResponseCache({
4128-
enabled(context: any): boolean {
4129-
return true;
4130-
}, session(context: any): string | undefined | null {
4131-
return "sessionString";
4132-
},
4133-
ttl:0
4134-
}),
4135-
],
4136-
schema,
4127+
[
4128+
useEngine({ ...GraphQLJS, execute: normalizedExecutor, subscribe: normalizedExecutor }),
4129+
useResponseCache({
4130+
enabled(context: any): boolean {
4131+
return true;
4132+
},
4133+
session(context: any): string | undefined | null {
4134+
return 'sessionString';
4135+
},
4136+
ttl: 0,
4137+
}),
4138+
],
4139+
schema,
41374140
);
41384141

41394142
const document = /* GraphQL */ `
@@ -4152,6 +4155,5 @@ it('id field in body overwritten and request fails', async () => {
41524155
}
41534156
`;
41544157

4155-
await expect( testkit.execute(document)).rejects.toThrow(TypeError);
4156-
4157-
});
4158+
await expect(testkit.execute(document)).rejects.toThrow(TypeError);
4159+
});

0 commit comments

Comments
 (0)