graphql-hive / graphql-hive/envelop

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

Open
#2,159 1 comment 0 reactions 0 assignees View on GitHub
kind/bug stage/0-issue-prerequisites
Dominant language
No language data
Stars
827
Forks
132
PR merge metrics
No merged PRs in 30d

Description

### Issue workflow progress

_Progress of the issue based on the
[Contributor Workflow](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md#a-typical-contributor-workflow)_

- [ ] 1. The issue provides a
[minimal reproduction](https://en.wikipedia.org/wiki/Minimal_reproducible_example) available on
[Stackblitz](https://stackblitz.com/fork/node).
- _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:

```ts
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;
```

**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).

```ts
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;
```

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.