dotansimha / dotansimha/graphql-code-generator
Optimize final introspection json schema
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Is your feature request related to a problem? Please describe.**
I'm using the below code (from [here](https://formidable.com/open-source/urql/docs/graphcache/schema-awareness/)) because I need an introspection schema in my SPA web app:
```js
import { getIntrospectionQuery } from "graphql";
import fetch from "node-fetch";
import * as fs from "fs";
fetch("http://localhost:3000/graphql", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
variables: {},
query: getIntrospectionQuery({ descriptions: false }),
}),
})
.then((result) => result.json())
.then(({ data }) => {
fs.writeFile("./schema.json", JSON.stringify(data), (err) => {
if (err) {
console.error("Writing failed:", err);
return;
}
console.log("Schema written!");
});
});
```
The amazing team at Urql also created packages for optimization: https://formidable.com/open-source/urql/docs/graphcache/schema-awareness/#optimizing-a-schema.
Using that solution my final schema .json is 35% smaller than the one generated by code-generator. And my final schema is part of the client bundle, so any BIT is important!
**Describe the solution you'd like**
Can we optimize like they did?
**Describe alternatives you've considered**
Maybe using options?
**Additional context**
I can use their solution, but it is very inconvenient especially in CI/CD environments where the GraphQL server is not active and I cannot verify the correct schema.
Generating from `*.graphql` files is amazing!
---
Thanks for your amazing work!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.