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

[useExtendedValidation] Passing context object to yoga breaks the server: "'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property (Cloudflare Workers) #2159

Open
4 tasks
Hebilicious opened this issue Feb 21, 2024 · 1 comment
Labels
kind/bug Something isn't working stage/0-issue-prerequisites Needs more information before we can start working on it

Comments

@Hebilicious
Copy link

Hebilicious commented Feb 21, 2024

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a
    minimal reproduction available on
    Stackblitz.
    • Please install the latest @envelop/* packages that you are using.
    • Please make sure the reproduction is as small as possible.
  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

Apologies for not providing a Stackblitz as the issue isn't reproducible there. However I can create a minimal reproduction repo if necessary

When using the extendedValidation plugin with cloudflare workers, the following error happens when passing a context object to yoga as the 2nd argument.

"'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property 'cloudflare' which is either non-existent or configurable in the proxy target"
image

The error happens with wrangler dev and with the deployed worker.
The error doesn't happen if using a regular runtime like Bun or Node.js.

To Reproduce Steps to reproduce the behavior:

export type CloudflareContext = { env: Env; context: ExecutionContext };

const yoga = createYoga<{ cloudflare: CloudflareContext }>({
	schema,
	context: async ({ request, cloudflare }) => {
		return { cloudflare };
	},
	plugins: [ useExtendedValidation({ rules: [] }) ]
});

export default {
	async fetch(request: Request, env, context) {
		const graphqlContext = {
			request,
			cloudflare: { env, context }
		};
		return yoga(request, graphqlContext);
	}
} satisfies ExportedHandler<Env>;

Expected behavior

No error.

Environment:

  • OS: macOs m1
  • NodeJS: Workerd, wrangler 3.28.4
  • @envelop/* versions: 4.0.0
  • @envelop/core: no
  • graphql : 16.8.1

Additional context

Investigating further, I found out that if I pass an array instead of an object, everything works (Typescript get lost though).

const yoga = createYoga<[{ request: Request; cloudflare: CloudflareContext }]>(//...)
export default {
	async fetch(request: Request, env, context) {
		const graphqlContext = [{ request, cloudflare: { env, context } }] as const;
		//@ts-expect-error ignore this error
		return yoga(request, graphqlContext) as Response;
	}
} satisfies ExportedHandler<Env>;

I also encountered the same error with SvelteKit, however I did not try the workaround.

@Hebilicious Hebilicious changed the title [useExtendedValidation] (Cloudflare Workers) [useExtendedValidation] "'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property (Cloudflare Workers) Feb 21, 2024
@Hebilicious Hebilicious changed the title [useExtendedValidation] "'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property (Cloudflare Workers) [useExtendedValidation] Passing context object to yoga breaks the server: "'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property (Cloudflare Workers) Feb 21, 2024
@EmrysMyrddin EmrysMyrddin added kind/bug Something isn't working stage/0-issue-prerequisites Needs more information before we can start working on it labels Mar 22, 2024
@EmrysMyrddin
Copy link
Collaborator

Hi, we have made some changes to the way the server context is handled, can you try to update to latest version please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working stage/0-issue-prerequisites Needs more information before we can start working on it
Projects
None yet
Development

No branches or pull requests

2 participants