-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rishabh Chawla
committed
Dec 11, 2023
1 parent
a43a69a
commit 58010f0
Showing
1 changed file
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,75 @@ | ||
# graphql-tag-swc-plugin | ||
> Info | ||
> # WIP | ||
> uses `swc_core` crate, use legacy branch for support with nextjs | ||
|
||
SWC plugin alternative to `babel-plugin-graphql-tag` | ||
|
||
## Installation | ||
|
||
``` | ||
npm install -D graphql-tag-swc-plugin | ||
``` | ||
|
||
## Usage | ||
|
||
### SWC | ||
|
||
Add following to swc config (below with default values): | ||
|
||
``` | ||
jsc: { | ||
experimental: { | ||
plugins: [ | ||
["graphql-tag-swc-plugin", | ||
{ | ||
importSources: ["@apollo/client", "graphql-tag"], | ||
gqlTagIdentifiers: ["gql"] | ||
}, | ||
], | ||
], | ||
}, | ||
}, | ||
``` | ||
|
||
### Next js | ||
|
||
Add following to next config (below with default values): | ||
|
||
``` | ||
experimental: { | ||
swcPlugins: [ | ||
["graphql-tag-swc-plugin", | ||
{ | ||
importSources: ["@apollo/client", "graphql-tag"], | ||
gqlTagIdentifiers: ["gql"] | ||
}, | ||
], | ||
], | ||
}, | ||
``` | ||
|
||
## Configuration | ||
|
||
Following props are accepted by plugin currently, inline with babel alternative: | ||
|
||
1. `importSources`: | ||
> default: `["@apollo/client", "graphql-tag"]` | ||
import paths from where gql tag is imported for which plugin should compile graphql | ||
|
||
2. `gqlTagIdentifiers`: | ||
> default: `["gql"]` | ||
Identifier by which graphql-tag will be imported. | ||
Example: Here `import { gql } from "@apollo/client`, `"gql"` is the identifier. | ||
|
||
## Contribution | ||
|
||
All contributions are welcome! | ||
For any bug / feature request please create a Pull request with fixture for the same whenever possible. | ||
|
||
## Authors | ||
|
||
- @rishabh3112 - Rishabh Chawla | ||
|
||
## License | ||
|
||
MIT |