Skip to content

Commit

Permalink
fix: Maximum call stack size exceeded for schema build with cross ref…
Browse files Browse the repository at this point in the history
…erenced types
  • Loading branch information
nodkz committed Aug 22, 2016
1 parent 3f41ef8 commit 27a38ea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/storage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* @flow */

import TypeComposer from './typeComposer';
import { GraphQLObjectType, GraphQLSchema } from 'graphql';
import { GraphQLObjectType, GraphQLSchema, getNamedType } from 'graphql';

import type ResolverList from './resolver/resolverList';
import type Resolver from './resolver/resolver';
Expand Down Expand Up @@ -103,8 +103,10 @@ export default class ComposeStorage {

const fields = typeComposer.getFields();
Object.keys(fields).forEach(fieldName => {
const fieldType = fields[fieldName].type;
if (fieldType instanceof GraphQLObjectType) {
const typeAndField = `${typeComposer.getTypeName()}.${fieldName}`;
const fieldType = getNamedType(fields[fieldName].type);
if (fieldType instanceof GraphQLObjectType && !createdRelations.has(typeAndField)) {
createdRelations.add(typeAndField);
this.buildRelations(new TypeComposer(fieldType), createdRelations);
}
});
Expand Down

0 comments on commit 27a38ea

Please sign in to comment.