Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Add list of users under company and fix circular reference
Browse files Browse the repository at this point in the history
  • Loading branch information
sicktastic committed Nov 3, 2017
1 parent 0158188 commit cb9c26c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions graphql/schema/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ const {
GraphQLObjectType,
GraphQLString,
GraphQLInt,
GraphQLSchema
GraphQLSchema,
GraphQLList
} = graphql;

const CompanyType = new GraphQLObjectType({
name: 'Company',
fields: {
fields: () => ({
id: { type: GraphQLString },
name: { type: GraphQLString },
description: { type: GraphQLString }
}
description: { type: GraphQLString },
users: {
type: new GraphQLList(UserType),
resolve(parentValue, args) {
return axios.get(`http://localhost:3000/companies/${parentValue.id}/users`)
.then(resp => resp.data);
}
}
})
});

const UserType = new GraphQLObjectType({
Expand Down

0 comments on commit cb9c26c

Please sign in to comment.