Skip to content

Commit

Permalink
Fixed #3 - graphql non-null links now work
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorDiaconu committed Jul 31, 2018
1 parent dec6e41 commit 4054131
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions LinkDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ export default class LinkDirective extends SchemaDirectiveVisitor {
referencedType = field.type;
}

if (!(referencedType instanceof GraphQLObjectType)) {
throw new Meteor.Error(
'invalid-type',
`You are trying to attach a link on a invalid type. @link directive only works with GraphQLObjectType `
);
if (referencedType instanceof GraphQLNonNull) {
referencedType = referencedType.ofType;
} else {
if (!(referencedType instanceof GraphQLObjectType)) {
throw new Meteor.Error(
'invalid-type',
`You are trying to attach a link on a invalid type. @link directive only works with GraphQLObjectType `
);
}
}

let referencedCollectionName = referencedType._mongoCollectionName;
Expand Down

0 comments on commit 4054131

Please sign in to comment.