project_nextjs13_flexibble
project_nextjs13_flexibble copied to clipboard
ClientError: Unauthorized to access Mutation.userCreate (missing create operation):
I am getting this issue while signing in
ClientError: Unauthorized to access Mutation.userCreate (missing create operation): {"response":{"data":null,"errors":[{"message":"Unauthorized to access Mutation.userCreate (missing create operation)"}],"status":200,"headers":{}},"request":{"query":"\n\tmutation CreateUser($input: UserCreateInput!) {\n\t\tuserCreate(input: $input) {\n\t\t\tuser {\n\t\t\t\tname\n\t\t\t\temail\n\t\t\t\tavatarUrl\n\t\t\t\tdescription\n\t\t\t\tgithubUrl\n\t\t\t\tlinkedInUrl\n\t\t\t\tid\n\t\t\t}\n\t\t}\n\t}\n","variables":{"variables":{"input":{"name":"Salman Sheriff","email":"[email protected]","avatarUrl":"https://avatars.githubusercontent.com/u/95226945?v=4"}}}}} at makeRequest (webpack-internal:///(sc_server)/./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/graphql-request/build/esm/index.js:288:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async makeGraphQLRequest (webpack-internal:///(sc_server)/./src/lib/actions.ts:17:16) at async Object.signIn (webpack-internal:///(sc_server)/./src/lib/session/index.ts:55:21) at async Object.callback (webpack-internal:///(sc_server)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/core/routes/callback.js:49:39) at async AuthHandler (webpack-internal:///(sc_server)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/core/index.js:202:38) at async NextAuthRouteHandler (webpack-internal:///(sc_server)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/next/index.js:49:30) at async NextAuth._args$ (webpack-internal:///(sc_server)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/next/index.js:83:24) at async eval (webpack-internal:///(sc_server)/./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/future/route-modules/app-route/module.js:265:37) { response: { data: null, errors: [ [Object] ], status: 200, headers: Headers { [Symbol(map)]: [Object: null prototype] } }, request: { query: '\n' + '\tmutation CreateUser($input: UserCreateInput!) {\n' + '\t\tuserCreate(input: $input) {\n' + '\t\t\tuser {\n' + '\t\t\t\tname\n' + '\t\t\t\temail\n' + '\t\t\t\tavatarUrl\n' + '\t\t\t\tdescription\n' + '\t\t\t\tgithubUrl\n' + '\t\t\t\tlinkedInUrl\n' + '\t\t\t\tid\n' + '\t\t\t}\n' + '\t\t}\n' + '\t}\n',
variables: { variables: [Object] }
} }
In graphql/index.ts
, check the fields.
IncreateUserMutation
, I think it should be linkedinUrl
instead of linkedInUrl
.
Or just make it uniform in all files.
Hey, I used to have the exact same error response at node terminal, and actually want to create another post about it.
This error occured around 01:40:00 at the youtube video when testing the google auth
I spent another minute and it TURNS OUT that I have MISSED TYPED at lib/session.ts
❌
client.setHeader('xapi-key', apiKey)
✔
client.setHeader('x-api-key', apiKey
✔ Full Code `export const getUser = (email: string) => { client.setHeader('x-api-key', apiKey) return makeGraphQLRequest(getUserQuery, { email }) }
export const createUser = (name: string, email: string, avatarUrl: string) => { client.setHeader('x-api-key', apiKey)
const variables = {
input: {
name: name,
email: email,
avatarUrl: avatarUrl
},
};
return makeGraphQLRequest(createUserMutation, variables);
};`
I dont know if you have the same error, or this answer will solve your problem. but just check everything around those minutes.
and for what ever happend, dont give up on programming ✨
Well I have something interesting. I am getting this error:
Error checking if user exists: Invalid value for argument "input", field "description" of type "UserCreateInput" is required but not provided: {"response":{"data":null,"errors":[{"message":"Invalid value for argument "input", field "description" of type "UserCreateInput" is required but not provided","locations":[{"line":3,"column":14}]}],"status":200,"headers":{}},"request":{"query":"\n\tmutation CreateUser($input: UserCreateInput!) {\n\t\tuserCreate(input: $input) {\n\t\t\tuser {\n\t\t\t\tname\n\t\t\t\temail\n\t\t\t\tavatarUrl\n\t\t\t\tdescription\n\t\t\t\tgithubUrl\n linkedInUrl\n\t\t\t\tid\n\t\t\t}\n\t\t}\n\t}\n","variables":{"input":{"name":"Malik Dixon","email":"[email protected]","avatarUrl":"https://lh3.googleusercontent.com/a/AAcHTtd6-NST8PzhcJWtyYW2g-YbeZuhIHWZJz8bz4UCSh4ABw=s96-c"}}}}
How do we correct this error? I appreciate the assistance.
Hi. I also get this error while doing the edit project page. Here's the code
`export const updateProject = async ( form: ProjectForm, projectId: string, token: string ) => { function isBase64DataURL(value: string) { const base64Regex = /^data:image/[a-z]+;base64,/; return base64Regex.test(value); }
let updatedForm = { ...form };
const isUploadingNewImage = isBase64DataURL(form.image);
if (isUploadingNewImage) {
const imageUrl = await uploadImage(form.image);
if (imageUrl.url) {
updatedForm = { ...updatedForm, image: imageUrl.url };
}
}
client.setHeader("Authorization", `Bearer ${token}`);
const variables = {
id: projectId,
input: updatedForm,
};
return makeGraphQLRequest(updateProjectMutation, variables);
};`
the graphql mutation:
export const updateProjectMutation =
mutation updateProject(
$id: ID!
$input: ProjectUpdateInput!
) {
projectUpdate(
by: { id: $id }
input: $input
) {
project {
title
description
createdBy {
email
name
}
}
}
}
;
ClientError { response: { data: null, errors: [ { message: 'Unauthorized to access Mutation.projectUpdate (missing update operation)' } ], status: 200, headers: Headers { map: { 'cache-control': 'public, max-age: 0', 'content-length': '111', 'content-type': 'application/json;charset=UTF-8', 'x-grafbase-cache': 'MISS' } } }, request: { query: '\n' + ' mutation updateProject(\n' + ' $id: ID!\n' + ' $input: ProjectUpdateInput!\n' + ' ) {\n' + ' projectUpdate(\n' + ' by: { id: $id }\n' + ' input: $input\n' + ' ) {\n' + ' project {\n' + ' title\n' + ' description\n' + ' createdBy {\n' + ' email\n' + ' name\n' + ' }\n' + ' }\n' + ' }\n' + ' }\n' + '\n' + '', variables: { id: 'project_01H6DX3194M8Q7JKZN7346ZEVG', input: { title: 'Chill', description: 'https://www.pinterest.com/', image: 'http://res.cloudinary.com/dj-event-14/image/upload/v1690537589/cyeqj4g2e6btdz1wy1ac.jpg', liveSiteUrl: 'https://www.pinterest.com/', githubUrl: 'https://www.pinterest.com/', category: 'Backend' } } }, stack: 'Error: Unauthorized to access Mutation.projectUpdate (missing update operation): {"response":{"data":null,"errors":[{"message":"Unauthorized to access Mutation.projectUpdate (missing update operation)"}],"status":200,"headers":{"map":{"cache-control":"public, max-age: 0","content-length":"111","content-type":"application/json;charset=UTF-8","x-grafbase-cache":"MISS"}}},"request":{"query":"\n mutation updateProject(\n $id: ID!\n $input: ProjectUpdateInput!\n ) {\n projectUpdate(\n by: { id: $id }\n input: $input\n ) {\n project {\n title\n description\n createdBy {\n email\n name\n }\n }\n }\n }\n\n","variables":{"id":"project_01H6DX3194M8Q7JKZN7346ZEVG","input":{"title":"Chill","description":"https://www.pinterest.com/","image":"http://res.cloudinary.com/dj-event-14/image/upload/v1690537589/cyeqj4g2e6btdz1wy1ac.jpg","liveSiteUrl":"https://www.pinterest.com/","githubUrl":"https://www.pinterest.com/","category":"Backend"}}}}\n' + ' at makeRequest (webpack-internal:///(app-client)/./node_modules/graphql-request/build/esm/index.js:301:15)\n' + ' at async makeGraphQLRequest (webpack-internal:///(app-client)/./lib/actions.ts:48:16)\n' + ' at async handleFormSubmit (webpack-internal:///(app-client)/./components/ProjectForm.tsx:72:17)', message: 'Unauthorized to access Mutation.projectUpdate (missing update operation): {"response":{"data":null,"errors":[{"message":"Unauthorized to access Mutation.projectUpdate (missing update operation)"}],"status":200,"headers":{"map":{"cache-control":"public, max-age: 0","content-length":"111","content-type":"application/json;charset=UTF-8","x-grafbase-cache":"MISS"}}},"request":{"query":"\n mutation updateProject(\n $id: ID!\n $input: ProjectUpdateInput!\n ) {\n projectUpdate(\n by: { id: $id }\n input: $input\n ) {\n project {\n title\n description\n createdBy {\n email\n name\n }\n }\n }\n }\n\n","variables":{"id":"project_01H6DX3194M8Q7JKZN7346ZEVG","input":{"title":"Chill","description":"https://www.pinterest.com/","image":"http://res.cloudinary.com/dj-event-14/image/upload/v1690537589/cyeqj4g2e6btdz1wy1ac.jpg","liveSiteUrl":"https://www.pinterest.com/","githubUrl":"https://www.pinterest.com/","category":"Backend"}}}}' }
I don't know what went wrong.
Hi. I also get this error while doing the edit project page. Here's the code
`export const updateProject = async ( form: ProjectForm, projectId: string, token: string ) => { function isBase64DataURL(value: string) { const base64Regex = /^data:image/[a-z]+;base64,/; return base64Regex.test(value); }
let updatedForm = { ...form }; const isUploadingNewImage = isBase64DataURL(form.image); if (isUploadingNewImage) { const imageUrl = await uploadImage(form.image); if (imageUrl.url) { updatedForm = { ...updatedForm, image: imageUrl.url }; } } client.setHeader("Authorization", `Bearer ${token}`); const variables = { id: projectId, input: updatedForm, }; return makeGraphQLRequest(updateProjectMutation, variables);
};`
the graphql mutation:
export const updateProjectMutation =
mutation updateProject( $id: ID! $input: ProjectUpdateInput! ) { projectUpdate( by: { id: $id } input: $input ) { project { title description createdBy { email name } } } };
ClientError { response: { data: null, errors: [ { message: 'Unauthorized to access Mutation.projectUpdate (missing update operation)' } ], status: 200, headers: Headers { map: { 'cache-control': 'public, max-age: 0', 'content-length': '111', 'content-type': 'application/json;charset=UTF-8', 'x-grafbase-cache': 'MISS' } } }, request: { query: '\n' + ' mutation updateProject(\n' + ' $id: ID!\n' + ' $input: ProjectUpdateInput!\n' + ' ) {\n' + ' projectUpdate(\n' + ' by: { id: $id }\n' + ' input: $input\n' + ' ) {\n' + ' project {\n' + ' title\n' + ' description\n' + ' createdBy {\n' + ' email\n' + ' name\n' + ' }\n' + ' }\n' + ' }\n' + ' }\n' + '\n' + '', variables: { id: 'project_01H6DX3194M8Q7JKZN7346ZEVG', input: { title: 'Chill', description: 'https://www.pinterest.com/', image: 'http://res.cloudinary.com/dj-event-14/image/upload/v1690537589/cyeqj4g2e6btdz1wy1ac.jpg', liveSiteUrl: 'https://www.pinterest.com/', githubUrl: 'https://www.pinterest.com/', category: 'Backend' } } }, stack: 'Error: Unauthorized to access Mutation.projectUpdate (missing update operation): {"response":{"data":null,"errors":[{"message":"Unauthorized to access Mutation.projectUpdate (missing update operation)"}],"status":200,"headers":{"map":{"cache-control":"public, max-age: 0","content-length":"111","content-type":"application/json;charset=UTF-8","x-grafbase-cache":"MISS"}}},"request":{"query":"\n mutation updateProject(\n $id: ID!\n $input: ProjectUpdateInput!\n ) {\n projectUpdate(\n by: { id: $id }\n input: $input\n ) {\n project {\n title\n description\n createdBy {\n email\n name\n }\n }\n }\n }\n\n","variables":{"id":"project_01H6DX3194M8Q7JKZN7346ZEVG","input":{"title":"Chill","description":"https://www.pinterest.com/","image":"http://res.cloudinary.com/dj-event-14/image/upload/v1690537589/cyeqj4g2e6btdz1wy1ac.jpg","liveSiteUrl":"https://www.pinterest.com/","githubUrl":"https://www.pinterest.com/","category":"Backend"}}}}\n' + ' at makeRequest (webpack-internal:///(app-client)/./node_modules/graphql-request/build/esm/index.js:301:15)\n' + ' at async makeGraphQLRequest (webpack-internal:///(app-client)/./lib/actions.ts:48:16)\n' + ' at async handleFormSubmit (webpack-internal:///(app-client)/./components/ProjectForm.tsx:72:17)', message: 'Unauthorized to access Mutation.projectUpdate (missing update operation): {"response":{"data":null,"errors":[{"message":"Unauthorized to access Mutation.projectUpdate (missing update operation)"}],"status":200,"headers":{"map":{"cache-control":"public, max-age: 0","content-length":"111","content-type":"application/json;charset=UTF-8","x-grafbase-cache":"MISS"}}},"request":{"query":"\n mutation updateProject(\n $id: ID!\n $input: ProjectUpdateInput!\n ) {\n projectUpdate(\n by: { id: $id }\n input: $input\n ) {\n project {\n title\n description\n createdBy {\n email\n name\n }\n }\n }\n }\n\n","variables":{"id":"project_01H6DX3194M8Q7JKZN7346ZEVG","input":{"title":"Chill","description":"https://www.pinterest.com/","image":"http://res.cloudinary.com/dj-event-14/image/upload/v1690537589/cyeqj4g2e6btdz1wy1ac.jpg","liveSiteUrl":"https://www.pinterest.com/","githubUrl":"https://www.pinterest.com/","category":"Backend"}}}}' }
I don't know what went wrong.
Missing id
of Project https://github.com/adrianhajdin/project_nextjs13_flexibble/blob/956773362ea1f2248ec2c969a556420a061f0927/graphql/index.ts#L21C6-L21C6
I had similar issue when creating new project, it turned out I left a colon ":" after Bearer in the setHeader()...
client.setHeader("Authorization",
Bearer: ${token});
and it should be like this
client.setHeader("Authorization",
Bearer ${token});