ardatan / ardatan/graphql-import
Typescript *.graphql baking
- Dominant language
- No language data
- Stars
- 864
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to make use of graphql-import with typescript, It loads files fine but I still have to find a way to copy the .qraphql files to a dist folder... which mean involving some more complex build steps. And the idea of maintain both a `*.graphql` version and `*.graphql.ts` version is not ideal.
While I haven't considered all the other existing proposals and how they might solve this, I'm considering trying out something like the following, to achieve the functionality i desire:
Folder structure for a singe entity
```
- Book
-- index.ts
-- query.qraphql
-- query.qraphql.ts
-- resolver.ts
-- schema.qraphql
-- schema.qraphql.ts
```
*.qraphql.ts
```
import { importSchema } from "graphql-import"
export const Query:string = importSchema(__dirname + '/' + __filename.replace('.ts',''));
```
when I build i want to take the `*.qraphql` content loaded and replaces the importSchema with the actual graphql schema/query string. so that the dist folder will contain a baked version of the graphql schema/query at build time.
Thoughts?
**EDIT:** Better yet, potentially I can build cli tool that makes use of this module to watch files and bake them into `.js` / `.ts` files that export the graphql schema/query string on change.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the proposed *.graphql.ts structure and how graphql-import currently loads schema files. Define the build-time or watch-mode behavior, including generated .js/.ts output and dist placement; done means GraphQL content is available without copying separate .graphql files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100