Skip to content

Commit 0b18cc3

Browse files
committed
fix(visitAllArgs): skip wrapping of fields of Introspection types
the field type was not sufficient, skip wrapping if the parent field has introspection type
1 parent b3d98d6 commit 0b18cc3

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"typescript": {
1111
"definition": "dist/index.d.ts"
1212
},
13-
"repository": "https://github.com/tgerk/graphql-middleware-typed-arguments",
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/tgerk/graphql-middleware-typed-arguments.git"
16+
},
1417
"author": "Tim Gerk <[email protected]>, Matic Zavadlal <[email protected]>",
1518
"scripts": {
1619
"prepare": "npm run test",
@@ -22,7 +25,7 @@
2225
"pretty": "npx prettier --ignore-path .gitignore src{,/**}/{*.ts,*.js} --write"
2326
},
2427
"dependencies": {
25-
"graphql-middleware": "1.7.8",
28+
"graphql-middleware": "^2.0.2",
2629
"graphql-upload": "^8.0.1"
2730
},
2831
"devDependencies": {
@@ -45,10 +48,6 @@
4548
"branch": "master"
4649
},
4750
"homepage": "https://github.com/tgerk/graphql-middleware-typed-arguments",
48-
"repository": {
49-
"type": "git",
50-
"url": "https://github.com/tgerk/graphql-middleware-typed-arguments.git"
51-
},
5251
"bugs": {
5352
"url": "https://github.com/tgerk/graphql-middleware-typed-arguments/issues"
5453
},

src/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ function getFieldArguments(info: GraphQLResolveInfo): GraphQLArgument[] {
4747
return typeFields[fieldName].args
4848
}
4949

50-
function fieldHasIntrospectionType(info) {
51-
const { fieldName, parentType } = info
52-
const typeFields = parentType.getFields()
53-
return isIntrospectionType(typeFields[fieldName].type)
54-
}
55-
5650
/**
5751
*
5852
* @param type
@@ -220,8 +214,7 @@ export function processTypeArgs<V, T>({
220214

221215
export function visitAllArgs({ transform }): IMiddlewareFunction {
222216
return (resolve, parent, args, ctx, info) => {
223-
// TODO avoid introspection types--very fussy about introducing async into sync code
224-
if (!fieldHasIntrospectionType(info)) {
217+
if (!isIntrospectionType(info.parentType)) {
225218
const argDefs = getFieldArguments(info)
226219
if (argDefs.length) {
227220
// Apply argument transform function to all arguments

0 commit comments

Comments
 (0)