@soda-gql/core 0.11.26 → 0.12.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 CHANGED
@@ -33,36 +33,37 @@ import { gql } from "@/graphql-system";
33
33
 
34
34
  ### Writing Fragments
35
35
 
36
- Fragments define reusable field selections for a specific GraphQL type:
36
+ Fragments define reusable field selections for a specific GraphQL type using tagged template syntax:
37
37
 
38
38
  ```typescript
39
39
  export const userFragment = gql.default(({ fragment }) =>
40
- fragment.User({
41
- fields: ({ f }) => ({
42
- ...f.id(),
43
- ...f.name(),
44
- ...f.email(),
45
- }),
46
- }),
40
+ fragment("UserFragment", "User")`{
41
+ id
42
+ name
43
+ email
44
+ }`(),
47
45
  );
48
46
  ```
49
47
 
50
48
  ### Writing Operations
51
49
 
52
- Operations define complete GraphQL queries, mutations, or subscriptions:
50
+ Operations define complete GraphQL queries, mutations, or subscriptions. Use tagged template syntax for standalone operations:
53
51
 
54
52
  ```typescript
55
- export const getUserQuery = gql.default(({ query, $var }) =>
56
- query.operation({
57
- name: "GetUser",
58
- variables: { ...$var("id").ID("!") },
59
- fields: ({ f, $ }) => ({
60
- ...f.user({ id: $.id })(({ f }) => ({ ...f.id(), ...f.name() })),
61
- }),
62
- }),
53
+ export const getUserQuery = gql.default(({ query }) =>
54
+ query("GetUser")`($id: ID!) {
55
+ user(id: $id) {
56
+ id
57
+ name
58
+ }
59
+ }`(),
63
60
  );
61
+ ```
62
+
63
+ Use callback builders when you need fragment spreads in operations:
64
64
 
65
- // Operation with spread fragment
65
+ ```typescript
66
+ // Operation with spread fragment (callback builder required)
66
67
  export const getUserWithFragment = gql.default(({ query, $var }) =>
67
68
  query.operation({
68
69
  name: "GetUserWithFragment",