Skip to content

Commit

Permalink
Fix non-null array bug
Browse files Browse the repository at this point in the history
Signed-off-by: Arda TANRIKULU <ardatanrikulu@gmail.com>
  • Loading branch information
ardatan committed Nov 6, 2018
1 parent 04fdfb1 commit fde72cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/core/tests/graphql-module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ describe('GraphQLModule', () => {
`directive @entity on OBJECT`,
`directive @field on FIELD_DEFINITION`,
`type A @entity { f: String }`,
`type Query { a: A }`,
`type Query { a: [A!] }`,
],
});
const m2 = new GraphQLModule({
typeDefs: [
`directive @entity on OBJECT`,
`directive @field on FIELD_DEFINITION`,
`type A @entity { f: String @field }`,
`type Query { a: A }`,
`type Query { a: [A!] }`,
],
});

Expand Down
2 changes: 1 addition & 1 deletion packages/epoxy/src/schema-mergers/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function mergeType(node: ObjectTypeDefinitionNode, existingNode: ObjectTy
loc: node.loc,
fields: mergeFields(node.fields, existingNode.fields),
directives: mergeDirectives(node.directives, existingNode.directives),
interfaces: mergeNamedTypeArray(node.interfaces, existingNode.interfaces),
interfaces: mergeNamedTypeArray(node.interfaces || [], existingNode.interfaces || []),
};
} catch (e) {
throw new Error(`Unable to merge GraphQL type "${node.name.value}": ${e.message}`);
Expand Down
8 changes: 5 additions & 3 deletions packages/epoxy/src/schema-mergers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ export function isGraphQLSchema(obj: any): obj is GraphQLSchema {
}

export function extractType(type: TypeNode): NamedTypeNode {
if (type.kind === 'ListType' || type.kind === 'NonNullType') {
return type.type as any;

let visitedType = type;
while (visitedType.kind === 'ListType' || visitedType.kind === 'NonNullType') {
visitedType = visitedType.type;
}
return visitedType as any;

return type as any;
}

0 comments on commit fde72cc

Please sign in to comment.