diff options
| author | Adam Soltys <[email protected]> | 2018-02-12 17:53:49 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2018-02-12 17:53:49 -0800 |
| commit | cbf91f53e6c97cdb76c293c46813fbc9a74f47e5 (patch) | |
| tree | c410b374ce2736960ea67923a55a319b1817a359 /mutations.js | |
| parent | ebd061cf34aff30033511f9f1ec10ac21d1dcd94 (diff) | |
| download | coinos-server-cbf91f53e6c97cdb76c293c46813fbc9a74f47e5.tar.gz coinos-server-cbf91f53e6c97cdb76c293c46813fbc9a74f47e5.zip | |
create user mutation
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) + } + }, + } + }) +} |
