I've beat on this issue for what seems like a week and nothing online solves it. No data object is returned, not even "null". I'm converting from a working REST CRUD app to GraphQL. Not as easy as I expected.
My mutation in Playground:
mutation createMember($input: MemberInput!) {
createMember (input: $input) {
first_name
last_name
user_name
}
}
Playground Query Variables below: (Not in the headers section.)
{
"input": {
"first_name": "John",
"last_name": "Creston",
"user_name": "jc"
}
}
The schema: (The queries work fine and the Member type, an entity in TypeORM, works with them and full REST CRUD.)
input MemberInput {
first_name: String!
last_name: String!
user_name: String!
}
type Mutation {
createMember(input: MemberInput!): Member!
}
type Query {
getMembers: [Member]
getMember(member_id: Int!): Member!
checkUserName(user_name: String): Member
checkEmail(email: String): Member
}
I don't see how the resolver could be the problem for this error message but I'll add the Nestjs resolver:
@Mutation('createMember')
async createMember(@Args('input') input: MemberInput): Promise<Members> {
console.log('input in resolver: ', input);
return await this.membersService.addItem(input);
}
The service works with REST and the queries so that should be a problem. The console.log in the resolver never appears in terminal.
From the Copy CURL button:
curl 'http://localhost:3000/graphql' -H 'Accept-Encoding: gzip,
deflate, br' -H 'Content-Type: application/json' -H 'Accept:
application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin:
http://localhost:3000' --data-binary '{"query":"mutation
createMember($input: MemberInput!) {\n createMember (input: $input)
{\n first_name\n middle_initial\n last_name\n
user_name\n pitch\n main_skill_title\n \tskill_id_array\n
skills_comments\n other_skills\n links\n country\n
email\n member_status\n }\n}"}' --compressed
$input
is missing. You can double check whether the variables are being sent by opening the network tab in your browser's dev tools and examining the request playground is making to your server. I can promise there is noinput
variable in the request body if you're seeing this error. – Daniel ReardenCOPY CURL
button and edit your question with the resulting command? – Daniel Rearden