Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0no-co/babel-plugin-modular-graphql
Modular GraphQL.js import paths without the hassle.
https://github.com/0no-co/babel-plugin-modular-graphql
babel babel-plugin graphql
Last synced: about 1 month ago
JSON representation
Modular GraphQL.js import paths without the hassle.
- Host: GitHub
- URL: https://github.com/0no-co/babel-plugin-modular-graphql
- Owner: 0no-co
- License: mit
- Created: 2020-04-15T18:37:59.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-13T18:19:59.000Z (about 3 years ago)
- Last Synced: 2024-05-23T07:04:30.386Z (7 months ago)
- Topics: babel, babel-plugin, graphql
- Language: JavaScript
- Homepage:
- Size: 62.5 KB
- Stars: 17
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-list - babel-plugin-modular-graphql
README
# babel-plugin-modular-graphql
A small transform plugin to cherry-pick GraphQL modules so you don’t have to.
Basically [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash) for [graphql](https://github.com/graphql/graphql-js).This automatically finds the most specific import from the graphql module's files and folders that works
across GraphQL.js v14, v15, and v16.## Getting Started
```sh
npm install --save-dev babel-plugin-modular-graphql
# or
yarn add --dev babel-plugin-modular-graphql
```And add the plugin to your Babel config; it doesn't take any options.
## Example
Imports like these:
```js
import { parse, Kind } from 'graphql';
```Become:
```js
import { parse } from "graphql/language/parser";
import { Kind } from "graphql/language/kinds";
```## Limitations
- The plugin currently does not support `require()`
- The plugin automatically generates an import-map that drills down into `graphql`'s files. This may break if files at a depth of 1–2 change their names.