This project's goal is to generate all queries, mutation, subscriptions, fragments and types for any GraphQL schema.
This is a development tool, so make sure you install it with --save-dev
or -D
.
npm install graphql-data-access-generator --save-dev
yarn add -D graphql-data-access-generator
All code generation can be demo'd by looking into the example directory
- Provide a
graphqlUrl
and optionally the required headers to authenticate. - Provide a
schemaFile
location to download the current GraphQL schema. - Provide a
destinationPath
where all generated code will be outputed (it will be TypeScript).
const generator = require('graphql-data-access-generator')
async function main () {
await generator({
graphqlUrl: "http://0.0.0.0:8055/graphql",
schemaFile: "/tmp/schema.graphql",
headers: {
"Authorization": "Bearer graphql-admin"
},
destinationPath: __dirname + "/generated",
});
}
main()
The current bundle size for this repository is 3.9MB
. All of it belongs to dist/index.js
.
The reason behind this file size is we're using @vercel/ncc
to generate one file with all the dependencies embedded to the generated dist/index.js
file. This makes this package have no real dependencies when being installed in your project.
Working with this approach enables us to use this piece of software today and in the future, as we can guarantee it will not collide with different library versions and breaking changes that could potentally be introduced in the future.