vite-plugin-graphql-loader 1.0.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +37 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -30,3 +30,40 @@ export default defineConfig({
30
30
  plugins: [graphqlLoader()],
31
31
  });
32
32
  ```
33
+
34
+ Now you can import queries from `.gql` or `.graphql` files.
35
+
36
+ `example.graphql`:
37
+
38
+ ```graphql
39
+ fragment ExampleFragment on example {
40
+ id
41
+ name
42
+ }
43
+
44
+ query ExampleQuery {
45
+ example {
46
+ ...ExampleFragment
47
+ }
48
+ }
49
+ ```
50
+
51
+ `example.js`:
52
+
53
+ ```javascript
54
+ import ExampleQuery, { ExampleFragment } from "./example.graphql";
55
+ ```
56
+
57
+ If you are using TypeScript, you will have to declare `.gql` or `.graphql` files:
58
+
59
+ `graphql.d.ts`:
60
+
61
+ ```typescript
62
+ declare module "*.gql";
63
+
64
+ // Or if you aren't using fragments:
65
+ // declare module "*.gql" {
66
+ // const Query: import("graphql").DocumentNode;
67
+ // export default Query;
68
+ // }
69
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-graphql-loader",
3
- "version": "1.0.4",
3
+ "version": "2.0.0",
4
4
  "description": "A Vite plugin for loading GraphQL files.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",