Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authenticated mutation fails #307

Open
narduin opened this issue Feb 13, 2023 · 0 comments
Open

Authenticated mutation fails #307

narduin opened this issue Feb 13, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@narduin
Copy link

narduin commented Feb 13, 2023

Environment

  • Operating System: Darwin
  • Node Version: v16.19.0
  • Nuxt Version: 3.2.0
  • Nitro Version: 2.2.1
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: app, modules, graphql-client
  • Runtime Modules: [email protected]
  • Build Modules: -
  • CMS: Directus 9.22.3

Describe the bug

Hello,
I'm running into a very similar issue as the one described here #204

I can query just fine but as soon as I try to execute a mutation: it fails.
I've tried setting a bearer token through .env as well as in nuxt.config. I've also tried setting a specific (admin) bearer header with codegenHeaders but no luck.

What's weird is I can execute the mutation just fine in a graphql external client (insomnia), so that tells me my token and permissions are probably fine.
What's nerve racking is that when I allow anyone (public role) to execute mutation: it succeeds.

Directus logs:
Schema is not configured to execute mutation operation.
which usually mean the request was made with insufficient rights.

Expected behaviour

The mutation should succeed with the bearer token set for the default client or with the one set in codegenHeaders

Reproduction

No response

Additional context

modules: ["nuxt-graphql-client"],
"graphql-client": {
	clients: {
		default: {
			host: "https://api.tld/graphql",
			token: {
				type: "Bearer",
				name: "Authorization",
				value: "DEFAULT_TOKEN",
			},
			codegenHeaders: {
				"Authorization": "Bearer ADMIN_TOKEN",
			},
		},
	},
}

I can provide a private reproduction if needed!
I had to downgrade node from 18.14 to 16.19 because of this codegen bug #295

Logs

No response

@narduin narduin added the bug Something isn't working label Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant