mirror of
https://github.com/seigler/graphql-playground
synced 2025-07-27 01:26:10 +00:00
feat(server): prevent mutations with null values
This commit is contained in:
parent
420a4739eb
commit
dcb2421890
1 changed files with 7 additions and 7 deletions
|
@ -1,12 +1,12 @@
|
|||
const {
|
||||
GraphQLSchema,
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
GraphQLID,
|
||||
GraphQLInt,
|
||||
GraphQLList,
|
||||
GraphQLSchema
|
||||
GraphQLNonNull
|
||||
} = require('graphql');
|
||||
const _ = require('lodash');
|
||||
|
||||
const Book = require('../models/book');
|
||||
const Author = require('../models/author');
|
||||
|
@ -79,8 +79,8 @@ const Mutation = new GraphQLObjectType({
|
|||
addAuthor: {
|
||||
type: AuthorType,
|
||||
args: {
|
||||
name: { type: GraphQLString },
|
||||
age: { type: GraphQLInt }
|
||||
name: { type: new GraphQLNonNull(GraphQLString) },
|
||||
age: { type: new GraphQLNonNull(GraphQLInt) }
|
||||
},
|
||||
resolve (parent, { name, age }) {
|
||||
const author = new Author({
|
||||
|
@ -93,9 +93,9 @@ const Mutation = new GraphQLObjectType({
|
|||
addBook: {
|
||||
type: BookType,
|
||||
args: {
|
||||
name: { type: GraphQLString },
|
||||
genre: { type: GraphQLString },
|
||||
authorId: { type: GraphQLID }
|
||||
name: { type: new GraphQLNonNull(GraphQLString) },
|
||||
genre: { type: new GraphQLNonNull(GraphQLString) },
|
||||
authorId: { type: new GraphQLNonNull(GraphQLID) }
|
||||
},
|
||||
resolve (parent, { name, genre, authorId }) {
|
||||
const book = new Book({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue