rollup-plugin-graphql-js-client-compiler
Converts GraphQL files and schema definitions into ES Modules for use with the graphql-js-client during build time, using rollup and graphql-js-client-compiler.
Usage
Development
Transform any .graphql
file (including schema definitions) into js client query builder syntax for use with graphql-js-client.
// rollup.config.js;; entry: 'main.js' dest: 'bundle.js' moduleName: 'myModule' format: 'cjs' plugins: // main.js;;; const client = types url: 'https://api.myproject.org'; client;
NOTE: The schema can be an IDL file with the .graphql
extension, or an introspection response in JSON format with the .json
extension.
This will include the entire schema, as represented with graphql-js-schema.
Production
For production builds, make sure to optimize the schema, only including fields that actually used in graphql documents. Often, the entire schema is not used by a single application. To enable optimization, tweak your config as follows:
// rollup.config.js;; entry: 'main.js' dest: 'bundle.js' moduleName: 'myModule' format: 'cjs' plugins:
The profileDocuments
option should be an array of minimatch patterns that match all queries included in your application or library.
NOTE: Profiling makes the compilation of the schema slower. It is advised to only use this option in production.