-
Notifications
You must be signed in to change notification settings - Fork 360
Expand file tree
/
Copy pathresolvers.ts
More file actions
37 lines (32 loc) · 793 Bytes
/
resolvers.ts
File metadata and controls
37 lines (32 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* eslint-disable @typescript-eslint/naming-convention */
import type { Resolvers, MeshContext } from '../../.mesh';
const resolvers: Resolvers = {
NewPetResponseUnion: {
__resolveType: (val: any) => {
return (val as any).foo
? 'NewPetResponse'
: 'Error';
},
},
Query: {
newPet: async (root, args, context: MeshContext, info): Promise<any> => {
const {
petId,
extraId
} = args;
const data = (await context.Swapi.Query.pet_by_petId({
root,
args: {
petId
},
context,
info,
})) as any;
console.log('Data from pet_by_petId', JSON.stringify(data, null, 4));
return {
foo: JSON.stringify(data)
};
},
},
};
export default resolvers;