diff --git a/packages/components/model-collection/src/graphql.js b/packages/components/model-collection/src/graphql.js index 5c76ff92b94efd9c3f8730419ba40071900bcaf2..ad8c631372b93eb32d45f05e57dfba15150293b5 100644 --- a/packages/components/model-collection/src/graphql.js +++ b/packages/components/model-collection/src/graphql.js @@ -3,8 +3,8 @@ const resolvers = { collection(_, { id }, ctx) { return ctx.connectors.Collection.fetchOne(id, ctx) }, - collections(_, { id }, ctx) { - return ctx.connectors.Collection.fetchAll(ctx) + collections(_, { where }, ctx) { + return ctx.connectors.Collection.fetchAll(where, ctx) }, }, Mutation: { diff --git a/packages/components/model-fragment/src/graphql.js b/packages/components/model-fragment/src/graphql.js index 324f19e3f625c5b63206ad32ca8615520bf6260e..24dadc45553a038e5ebb3605fd44a4c9a51ec956 100644 --- a/packages/components/model-fragment/src/graphql.js +++ b/packages/components/model-fragment/src/graphql.js @@ -3,8 +3,8 @@ const resolvers = { fragment(_, { id }, ctx) { return ctx.connectors.Fragment.fetchOne(id, ctx) }, - fragments(_, { id }, ctx) { - return ctx.connectors.Fragment.fetchAll(ctx) + fragments(_, { where }, ctx) { + return ctx.connectors.Fragment.fetchAll(where, ctx) }, }, Mutation: { diff --git a/packages/components/model-user/src/graphql.js b/packages/components/model-user/src/graphql.js index d4be96a95bb21ef9358b41105ac26b8049b874d3..1d26c3191343eafbd08200c2d28cbef8d2988c49 100644 --- a/packages/components/model-user/src/graphql.js +++ b/packages/components/model-user/src/graphql.js @@ -6,8 +6,8 @@ const resolvers = { user(_, { id }, ctx) { return ctx.connectors.User.fetchOne(id, ctx) }, - users(_, vars, ctx) { - return ctx.connectors.User.fetchAll(ctx) + users(_, { where }, ctx) { + return ctx.connectors.User.fetchAll(where, ctx, { eager: 'teams' }) }, // Authentication currentUser(_, vars, ctx) { @@ -16,7 +16,14 @@ const resolvers = { }, }, Mutation: { - createUser(_, { input }, ctx) { + async createUser(_, { input }, ctx) { + if (input.password) { + input.passwordHash = await ctx.connectors.User.model.hashPassword( + input.password, + ) + delete input.password + } + return ctx.connectors.User.create(input, ctx) }, deleteUser(_, { id }, ctx) { @@ -46,11 +53,6 @@ const resolvers = { } }, }, - User: { - teams(user, vars, ctx) { - return ctx.connectors.Team.fetchSome(user.teams, ctx) - }, - }, } const typeDefs = ` @@ -68,8 +70,8 @@ const typeDefs = ` type User { id: ID! type: String - username: String! - email: String! + username: String + email: String admin: Boolean teams: [Team!]! }