-
Notifications
You must be signed in to change notification settings - Fork 0
/
duplicate-resolve-property-name.spec.ts
63 lines (52 loc) · 1.86 KB
/
duplicate-resolve-property-name.spec.ts
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { printSchema } from 'graphql';
import { stripIndent } from 'common-tags';
import { ObjectType, Field, buildSchema } from 'type-graphql';
// import { Resolver, FieldResolver, Query } from 'type-graphql';
import { Resolver, ResolveProperty, Query } from '@nestjs/graphql';
import 'reflect-metadata';
/**
Test Output:
============
TypeError: Cannot read property 'getObjectType' of undefined
at definitions.forEach.def (node_modules/type-graphql/dist/metadata/metadata-storage.js:126:92)
at Array.forEach (<anonymous>)
at MetadataStorage.buildFieldResolverMetadata (node_modules/type-graphql/dist/metadata/metadata-storage.js:122:21)
at MetadataStorage.build (node_modules/type-graphql/dist/metadata/metadata-storage.js:77:14)
at Function.generateFromMetadataSync (node_modules/type-graphql/dist/schema/schema-generator.js:27:51)
at Function.<anonymous> (node_modules/type-graphql/dist/schema/schema-generator.js:16:33)
at node_modules/tslib/tslib.js:107:75
at Object.__awaiter (node_modules/tslib/tslib.js:103:16)
*/
it('duplicate ResolveProperty name', async () => {
@ObjectType()
class SampleObject {
@Field()
stringField: string;
}
@Resolver('SampleObject')
// @Resolver(SampleObject)
class SampleResolver {
// @FieldResolver(() => String, { name: 'modifiedName' })
@ResolveProperty('duplicatedNameField', () => String, {
name: 'modifiedName',
})
foo(): string {
return `What's my name?`;
}
@Query(() => SampleObject)
sampleQuery(): SampleObject {
return {} as any;
}
}
const schema = await buildSchema({ resolvers: [SampleResolver] });
expect(printSchema(schema)).toEqual(
stripIndent`
type Query {
sampleQuery: SampleObject!
}
type SampleObject {
stringField: String!
modifiedName: String!
}` + '\n'
);
});