graphql-input-string
graphql-input-string copied to clipboard
Getting the field name to return in an error
I am trying to get the name of the field that was caused the error and to return that in the error
TrimmedString: GraphQLInputString({
name: 'TrimmedString',
error (info) {
// somewhere in here get the name of the input field
// For instance if the field was email I can assign it to a fieldName variable and use it in here:
throw new GraphQLError(`The field ${fieldName} must not be empty.`)
}
trim: true
}),