You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(sdk): add toResolverOutput function for TailorDBType conversion
toResolverOutput() converts a TailorDBType to a resolver output type
that matches the TailorDB auto-generated query's return type.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: packages/sdk/docs/services/resolver.md
+56Lines changed: 56 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,6 +120,62 @@ createResolver({
120
120
});
121
121
```
122
122
123
+
## Custom Type Names
124
+
125
+
### Using `typeName()` for nested objects
126
+
127
+
When defining nested objects in input or output schemas, you can specify a custom GraphQL type name using the `typeName()` method. This is useful when you want to control the exact type name that appears in the GraphQL schema.
128
+
129
+
```typescript
130
+
createResolver({
131
+
name: "createProfile",
132
+
operation: "mutation",
133
+
input: {
134
+
profile: t
135
+
.object({
136
+
name: t.string(),
137
+
email: t.string(),
138
+
})
139
+
.typeName("ProfileInput"), // GraphQL type will be "ProfileInput"
140
+
},
141
+
body: (context) =>context.input.profile,
142
+
output: t
143
+
.object({
144
+
name: t.string(),
145
+
email: t.string(),
146
+
})
147
+
.typeName("ProfileOutput"), // GraphQL type will be "ProfileOutput"
148
+
});
149
+
```
150
+
151
+
Without `typeName()`, the SDK generates type names automatically (e.g., `CreateProfileProfile` for input).
152
+
153
+
### Using `toResolverOutput()` for TailorDB types
154
+
155
+
`toResolverOutput()` makes the resolver's output type match the TailorDB auto-generated query's return type. For example, if you have a `User` type in TailorDB, `toResolverOutput(user)` produces the same GraphQL type as the auto-generated `user` and `users` queries.
0 commit comments