@soda-gql/babel-plugin 0.1.0 → 0.2.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.
- package/README.md +11 -14
- package/dist/index.cjs +4 -610
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -580
- package/dist/index.mjs.map +1 -1
- package/package.json +29 -11
package/README.md
CHANGED
|
@@ -56,14 +56,14 @@ bun run soda-gql codegen
|
|
|
56
56
|
import { gql } from "@/graphql-system";
|
|
57
57
|
|
|
58
58
|
export const userQuery = gql.default(({ query }, { $var }) =>
|
|
59
|
-
query.
|
|
59
|
+
query.operation(
|
|
60
60
|
{
|
|
61
|
-
|
|
61
|
+
name: "GetUser",
|
|
62
62
|
variables: [$var("id").scalar("ID:!")],
|
|
63
63
|
},
|
|
64
|
-
({ f, $ }) =>
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
({ f, $ }) => [
|
|
65
|
+
f.user({ id: $.id })(({ f }) => [f.id(), f.name()]),
|
|
66
|
+
],
|
|
67
67
|
),
|
|
68
68
|
);
|
|
69
69
|
```
|
|
@@ -73,8 +73,7 @@ export const userQuery = gql.default(({ query }, { $var }) =>
|
|
|
73
73
|
```typescript
|
|
74
74
|
import { gqlRuntime } from "@soda-gql/runtime";
|
|
75
75
|
|
|
76
|
-
export const userQuery = gqlRuntime.
|
|
77
|
-
gqlRuntime.composedOperation("canonicalId", { /* ... */ });
|
|
76
|
+
export const userQuery = gqlRuntime.getOperation("canonicalId");
|
|
78
77
|
```
|
|
79
78
|
|
|
80
79
|
## Configuration Options
|
|
@@ -168,19 +167,19 @@ The plugin automatically handles both ESM and CommonJS:
|
|
|
168
167
|
**Input (ESM)**:
|
|
169
168
|
```typescript
|
|
170
169
|
import { gql } from "@/graphql-system";
|
|
171
|
-
export const
|
|
170
|
+
export const fragment = gql.default(/* ... */);
|
|
172
171
|
```
|
|
173
172
|
|
|
174
173
|
**Output (ESM)**:
|
|
175
174
|
```typescript
|
|
176
175
|
import { gqlRuntime } from "@soda-gql/runtime";
|
|
177
|
-
export const
|
|
176
|
+
export const fragment = gqlRuntime.fragment("canonicalId", /* ... */);
|
|
178
177
|
```
|
|
179
178
|
|
|
180
179
|
**Output (CommonJS)** - when using `@babel/plugin-transform-modules-commonjs`:
|
|
181
180
|
```javascript
|
|
182
181
|
const { gqlRuntime } = require("@soda-gql/runtime");
|
|
183
|
-
module.exports.
|
|
182
|
+
module.exports.fragment = gqlRuntime.fragment("canonicalId", /* ... */);
|
|
184
183
|
```
|
|
185
184
|
|
|
186
185
|
## Architecture
|
|
@@ -195,10 +194,8 @@ module.exports.model = gqlRuntime.model("canonicalId", /* ... */);
|
|
|
195
194
|
|
|
196
195
|
### Supported GraphQL Elements
|
|
197
196
|
|
|
198
|
-
- **
|
|
199
|
-
- **
|
|
200
|
-
- **Operations**: Composed operations from multiple slices
|
|
201
|
-
- **Inline Operations**: Self-contained operations
|
|
197
|
+
- **Fragments**: Fragment definitions with data normalization
|
|
198
|
+
- **Operations**: Query/mutation/subscription operations with field selections
|
|
202
199
|
|
|
203
200
|
## Comparison with Other Plugins
|
|
204
201
|
|