@soda-gql/babel-plugin 0.1.0 → 0.3.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 +12 -17
- 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,15 +56,13 @@ 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.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
({ f, $ }) => ({
|
|
65
|
-
user: f.user({ id: $.id })(({ f }) => [f.id(), f.name()]),
|
|
59
|
+
query.operation({
|
|
60
|
+
name: "GetUser",
|
|
61
|
+
variables: { ...$var("id").ID("!") },
|
|
62
|
+
fields: ({ f, $ }) => ({
|
|
63
|
+
...f.user({ id: $.id })(({ f }) => ({ ...f.id(), ...f.name() })),
|
|
66
64
|
}),
|
|
67
|
-
),
|
|
65
|
+
}),
|
|
68
66
|
);
|
|
69
67
|
```
|
|
70
68
|
|
|
@@ -73,8 +71,7 @@ export const userQuery = gql.default(({ query }, { $var }) =>
|
|
|
73
71
|
```typescript
|
|
74
72
|
import { gqlRuntime } from "@soda-gql/runtime";
|
|
75
73
|
|
|
76
|
-
export const userQuery = gqlRuntime.
|
|
77
|
-
gqlRuntime.composedOperation("canonicalId", { /* ... */ });
|
|
74
|
+
export const userQuery = gqlRuntime.getOperation("canonicalId");
|
|
78
75
|
```
|
|
79
76
|
|
|
80
77
|
## Configuration Options
|
|
@@ -168,19 +165,19 @@ The plugin automatically handles both ESM and CommonJS:
|
|
|
168
165
|
**Input (ESM)**:
|
|
169
166
|
```typescript
|
|
170
167
|
import { gql } from "@/graphql-system";
|
|
171
|
-
export const
|
|
168
|
+
export const fragment = gql.default(/* ... */);
|
|
172
169
|
```
|
|
173
170
|
|
|
174
171
|
**Output (ESM)**:
|
|
175
172
|
```typescript
|
|
176
173
|
import { gqlRuntime } from "@soda-gql/runtime";
|
|
177
|
-
export const
|
|
174
|
+
export const fragment = gqlRuntime.fragment("canonicalId", /* ... */);
|
|
178
175
|
```
|
|
179
176
|
|
|
180
177
|
**Output (CommonJS)** - when using `@babel/plugin-transform-modules-commonjs`:
|
|
181
178
|
```javascript
|
|
182
179
|
const { gqlRuntime } = require("@soda-gql/runtime");
|
|
183
|
-
module.exports.
|
|
180
|
+
module.exports.fragment = gqlRuntime.fragment("canonicalId", /* ... */);
|
|
184
181
|
```
|
|
185
182
|
|
|
186
183
|
## Architecture
|
|
@@ -195,10 +192,8 @@ module.exports.model = gqlRuntime.model("canonicalId", /* ... */);
|
|
|
195
192
|
|
|
196
193
|
### Supported GraphQL Elements
|
|
197
194
|
|
|
198
|
-
- **
|
|
199
|
-
- **
|
|
200
|
-
- **Operations**: Composed operations from multiple slices
|
|
201
|
-
- **Inline Operations**: Self-contained operations
|
|
195
|
+
- **Fragments**: Fragment definitions with data normalization
|
|
196
|
+
- **Operations**: Query/mutation/subscription operations with field selections
|
|
202
197
|
|
|
203
198
|
## Comparison with Other Plugins
|
|
204
199
|
|