swr-codegen
v0.3.0
Published
A powerful code generator that Generate SWR hooks from GraphQL queries & mutations
Downloads
11
Readme
SWR GraphQl Code Generator
A powerful code generator that Generate SWR hooks from GraphQL queries & mutations A Powerfull Code Generator For SWR
Table Of Contents
How to Use
Installing The Package:
⚠️ This package does not support global installation anymore,
you can install it in your project using:
npm i swr-codegen -d
Adding config file inside your project:
create a javascript file anywhere in your project e.g.
codegen-config.js
add your configs:
you can use the init command : swr-codegen --init
to create a config file with default configs, or you can create a config file manually:
const fs = require("fs");
module.exports = {
gqlGlob: "./**/*.gql",
targetPath: "/generated/swr/",
schema: async () => {
return fs.readFileSync("graphql/schema.graphql").toString();
},
};
- (optional) Add a codegen command to your package.json:
"scripts": {
...
"codegen": "swr-codegen --configPath=./codegen-config.js"
}
That's it! run npm run codegen
(or swr-codegen configPath=./codegen-config.js
)
High-Priority Tasks:
add a better error-handling system.
add an option to customize the EJS templates.
adding path normalizer
Repository Owners: