MichalLytek / MichalLytek/type-graphql

Make it work on edge functions

Open
#1,440 20 comments 0 reactions 0 assignees View on GitHub
Community :family_man_girl: Enhancement :new:
Dominant language
TypeScript
Stars
8.1k
Forks
672
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
`typegraphql` cannot work, at the moment, on edge function engines, like the one of cloudflare workers or vercel@edge. The only reason why it cannot work is because the "emit schema to file" feature relies on `path` and `fs` libraries. No other part of the code is problematic. This is a little shame because a secondary feature is preventing it to work.

**Describe the solution you'd like**
Since the only feature is `emitSchemaFile` we could isolate this functionality into a different package (e.g. `typegraphql-schema-emit` or as submodule `typegraphql/schema-emit`) and have it as optional peer dependency, so that, when the user want to use the non programmatic way of emitting schema they need that dependency. As well, when they want to use the programmatic way, they need to referthat dependency directly.

**Describe alternatives you've considered**
It's not easy to isolate some parts of a library. Maybe tree shaking can help but it's not easy.

Contributor guide

Open the contributing guide

Research direction

Start by locating the emitSchemaFile implementation and its imports of path and fs, then trace the package entry points that expose schema emission. Compare the programmatic and file-emission paths and verify that the requested separation preserves the existing feature while allowing edge-function usage without those Node libraries.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.