Skip to content

Commit 92605f1

Browse files
committed
Use native merging
- No need for lodash overhead - merge of lodash does recursivly merge which can be bad and time consuming
1 parent 51294b5 commit 92605f1

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/api/types/PetType.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
GraphQLObjectType,
66
GraphQLFieldConfigMap,
77
} from 'graphql';
8-
import { merge } from 'lodash';
98
import { OwnerType } from './UserType';
109
import { Pet } from '../models/Pet';
1110
import { GraphQLContext } from '../../lib/graphql';
@@ -28,18 +27,18 @@ const PetFields: GraphQLFieldConfigMap = {
2827
export const PetOfUserType = new GraphQLObjectType({
2928
name: 'PetOfUser',
3029
description: 'A users pet',
31-
fields: () => merge<GraphQLFieldConfigMap, GraphQLFieldConfigMap>(PetFields, {}),
30+
fields: () => ({ ...PetFields, ...{} }),
3231
});
3332

3433
export const PetType = new GraphQLObjectType({
3534
name: 'Pet',
3635
description: 'A single pet.',
37-
fields: () => merge<GraphQLFieldConfigMap, GraphQLFieldConfigMap>(PetFields, {
36+
fields: () => ({ ...PetFields, ...{
3837
owner: {
3938
type: OwnerType,
4039
description: 'The owner of the pet',
4140
resolve: (pet: Pet, args: any, context: GraphQLContext<any, any>) =>
4241
context.dataLoaders.users.load(pet.userId),
4342
},
44-
}),
43+
} }),
4544
});

src/api/types/UserType.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
GraphQLFieldConfigMap,
66
GraphQLList,
77
} from 'graphql';
8-
import { merge } from 'lodash';
98
import { GraphQLContext } from '../../lib/graphql';
109
import { PetOfUserType } from './PetType';
1110
import { User } from '../models/User';
@@ -32,7 +31,7 @@ const UserFields: GraphQLFieldConfigMap = {
3231
export const UserType = new GraphQLObjectType({
3332
name: 'User',
3433
description: 'A single user.',
35-
fields: () => merge<GraphQLFieldConfigMap, GraphQLFieldConfigMap>(UserFields, {
34+
fields: () => ({ ...UserFields, ...{
3635
pets: {
3736
type: new GraphQLList(PetOfUserType),
3837
description: 'The pets of a user',
@@ -42,11 +41,11 @@ export const UserType = new GraphQLObjectType({
4241
// This would be the case with a normal service, but not very fast
4342
// context.container.get<PetService>(PetService).findByUser(user),
4443
},
45-
}),
44+
} }),
4645
});
4746

4847
export const OwnerType = new GraphQLObjectType({
4948
name: 'Owner',
5049
description: 'The owner of a pet',
51-
fields: () => merge<GraphQLFieldConfigMap, GraphQLFieldConfigMap>(UserFields, {}),
50+
fields: () => ({ ...UserFields, ...{} }),
5251
});

0 commit comments

Comments
 (0)