diff options
Diffstat (limited to 'mutations.js')
| -rw-r--r-- | mutations.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/mutations.js b/mutations.js new file mode 100644 index 00000000..795c885a --- /dev/null +++ b/mutations.js @@ -0,0 +1,38 @@ +import { resolver, defaultArgs, defaultListArgs, attributeFields } from 'graphql-sequelize' +import { + graphql, + GraphQLSchema, + GraphQLObjectType, + GraphQLInputObjectType, + GraphQLString, + GraphQLInt, + GraphQLNonNull, + GraphQLList +} from 'graphql' + +module.exports = (db, gqltypes) => { + const UserInputType = new GraphQLInputObjectType({ + name: 'UserInput', + desc: 'UserInput', + fields: { + ...attributeFields(db['User'], { exclude: ['id'] }), + } + }) + + return new GraphQLObjectType({ + name: 'mutation', + fields: { + createUser: { + type: gqltypes['users'], + args: { + user: { + type: UserInputType + } + }, + resolve: async (root, { user }) => { + return db['User'].create(user) + } + }, + } + }) +} |
