Skip to content

Commit f812c26

Browse files
committed
1 parent 11b0136 commit f812c26

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ const {
44
GraphQLInt,
55
GraphQLFloat,
66
GraphQLNonNull,
7-
GraphQLString
7+
GraphQLString,
8+
isWrappingType,
9+
isNamedType
810
} = require('graphql')
911
const { SchemaDirectiveVisitor } = require('graphql-tools')
1012
const ConstraintStringType = require('./scalars/string')
@@ -61,6 +63,17 @@ class ConstraintDirective extends SchemaDirectiveVisitor {
6163
} else {
6264
throw new Error(`Not a scalar type: ${field.type}`)
6365
}
66+
67+
const typeMap = this.schema.getTypeMap();
68+
let type = field.type;
69+
70+
if (isWrappingType(type)) {
71+
type = type.ofType;
72+
}
73+
74+
if (isNamedType(type) && !typeMap[type.name]) {
75+
typeMap[type.name] = type;
76+
}
6477
}
6578
}
6679

0 commit comments

Comments
 (0)