Skip to content

Commit 5936dc7

Browse files
committed
fixed type issues
1 parent 91b2349 commit 5936dc7

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

package.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@
2323
"@types/chai": "^4.1.4",
2424
"@types/mocha": "^5.2.5",
2525
"chai": "^4.1.2",
26-
"graphql": "^1.5.17",
2726
"mocha": "^5.2.0",
2827
"ts-mocha": "^2.0.0",
29-
"typescript": "^3.0.3"
30-
},
31-
"peerDependencies": {
32-
"graphql": "^14.5.8"
28+
"typescript": "^4.8.2"
3329
},
3430
"keywords": [
3531
"graphql",
3632
"mongodb",
3733
"generate",
3834
"backend",
3935
"binding"
40-
]
36+
],
37+
"dependencies": {
38+
"graphql": "^16.6.0"
39+
},
40+
"peerDependencies": {
41+
"graphql": "^15.0.0"
42+
}
4143
}

src/common.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GraphQLList, GraphQLType, GraphQLObjectType, GraphQLNonNull, GraphQLArgument, GraphQLFieldResolver, FieldDefinitionNode, GraphQLNamedType, GraphQLInterfaceType } from 'graphql'
1+
import { GraphQLList, GraphQLType, GraphQLObjectType, GraphQLNonNull, GraphQLArgument, GraphQLFieldResolver, FieldDefinitionNode, InputValueDefinitionNode, GraphQLNamedType, GraphQLInterfaceType,StringValueNode,NameNode,TypeNode,DirectiveNode,ValueNode } from 'graphql'
22

33
export interface cacheCallback<T> {
44
(key): T
@@ -29,7 +29,7 @@ export function setSuffix(text: string, locate: string, replaceWith: string): st
2929
: `${text}${replaceWith}`;
3030
}
3131

32-
export interface FieldExtensions {
32+
export type FieldExtensions = {
3333
graphqlToMongoDb?: { dependencies: string[] }
3434
}
3535

@@ -45,6 +45,17 @@ export interface FieldMap<T extends GraphQLType> {
4545
[key: string]: Field<T, any, any> & { type: T }
4646
}
4747

48+
export interface AstNodeType {
49+
readonly kind: any;
50+
readonly loc?: any;
51+
readonly description?: StringValueNode;
52+
readonly name: NameNode;
53+
readonly arguments?: ReadonlyArray<InputValueDefinitionNode>;
54+
readonly type: TypeNode;
55+
readonly directives?: ReadonlyArray<DirectiveNode>;
56+
readonly defaultValue?: ValueNode;
57+
}
58+
4859
export interface Field<TType extends GraphQLType,
4960
TSource,
5061
TContext,
@@ -53,12 +64,12 @@ export interface Field<TType extends GraphQLType,
5364
name?: string;
5465
description?: string;
5566
type: TType;
56-
args?: GraphQLArgument[];
67+
args?: readonly GraphQLArgument[];
5768
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
5869
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
5970
isDeprecated?: boolean;
6071
deprecationReason?: string;
61-
astNode?: FieldDefinitionNode;
72+
astNode?: AstNodeType;
6273
extensions?: FieldExtensions
6374
}
6475

src/mongoDbProjection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function getSelectedProjection(
4545

4646
if (options.isResolvedField(field)) {
4747
let dependencies: string[] = []
48-
if (field.extensions.graphqlToMongoDb) {
48+
if (field.extensions.graphqlToMongoDb && field.extensions.graphqlToMongoDb.dependencies) {
4949
dependencies = field.extensions.graphqlToMongoDb.dependencies;
5050
}
5151
const dependenciesProjection = dependencies.reduce((agg, dependency) => ({ ...agg, [dependency]: 1 }), {});

0 commit comments

Comments
 (0)