Skip to content

Commit

Permalink
feat(query): add support for query by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongjoon Cho committed May 23, 2017
1 parent 414c91e commit 38a7e8a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/type/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { addHooks } from '../utils';
import GraphQLDate from './custom/date';
import GraphQLBuffer from './custom/buffer';
import GraphQLGeneric from './custom/generic';
import createInputObject from './custom/to-input-object';
import { connectionFromModel, getOneResolver } from '../query';

// Registered types will be saved, we can access them later to resolve types
Expand Down Expand Up @@ -163,6 +164,23 @@ function getArguments(type, args = {}) {

if (field.type instanceof GraphQLScalarType) {
args[field.name] = field;
} else if (field.type instanceof GraphQLObjectType) {
if (field.type.name.endsWith('Connection')) {
args[field.name] = {
name: field.name,
type: new GraphQLList(GraphQLID)
};
} else if (field.type.mongooseEmbedded) {
args[field.name] = {
name: field.name,
type: createInputObject(field.type)
};
} else {
args[field.name] = {
name: field.name,
type: GraphQLID
};
}
}

return args;
Expand Down

0 comments on commit 38a7e8a

Please sign in to comment.