mirror of
https://github.com/seigler/graphql-playground
synced 2025-07-27 09:36:09 +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 {
|
const {
|
||||||
|
GraphQLSchema,
|
||||||
GraphQLObjectType,
|
GraphQLObjectType,
|
||||||
GraphQLString,
|
GraphQLString,
|
||||||
GraphQLID,
|
GraphQLID,
|
||||||
GraphQLInt,
|
GraphQLInt,
|
||||||
GraphQLList,
|
GraphQLList,
|
||||||
GraphQLSchema
|
GraphQLNonNull
|
||||||
} = require('graphql');
|
} = require('graphql');
|
||||||
const _ = require('lodash');
|
|
||||||
|
|
||||||
const Book = require('../models/book');
|
const Book = require('../models/book');
|
||||||
const Author = require('../models/author');
|
const Author = require('../models/author');
|
||||||
|
@ -79,8 +79,8 @@ const Mutation = new GraphQLObjectType({
|
||||||
addAuthor: {
|
addAuthor: {
|
||||||
type: AuthorType,
|
type: AuthorType,
|
||||||
args: {
|
args: {
|
||||||
name: { type: GraphQLString },
|
name: { type: new GraphQLNonNull(GraphQLString) },
|
||||||
age: { type: GraphQLInt }
|
age: { type: new GraphQLNonNull(GraphQLInt) }
|
||||||
},
|
},
|
||||||
resolve (parent, { name, age }) {
|
resolve (parent, { name, age }) {
|
||||||
const author = new Author({
|
const author = new Author({
|
||||||
|
@ -93,9 +93,9 @@ const Mutation = new GraphQLObjectType({
|
||||||
addBook: {
|
addBook: {
|
||||||
type: BookType,
|
type: BookType,
|
||||||
args: {
|
args: {
|
||||||
name: { type: GraphQLString },
|
name: { type: new GraphQLNonNull(GraphQLString) },
|
||||||
genre: { type: GraphQLString },
|
genre: { type: new GraphQLNonNull(GraphQLString) },
|
||||||
authorId: { type: GraphQLID }
|
authorId: { type: new GraphQLNonNull(GraphQLID) }
|
||||||
},
|
},
|
||||||
resolve (parent, { name, genre, authorId }) {
|
resolve (parent, { name, genre, authorId }) {
|
||||||
const book = new Book({
|
const book = new Book({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue