TypeScript Query Operations
In this section, we'll learn how to implement a Query Operation using TypeScript. We'll create a get
operation that returns a user by its ID.
Import the createOperation
function and the z
object from the wundergraph.factory
module. It's important that the result of createOperation
is exported as the default export of the file.
The route of the operation is derived from the file path. In this case, the file is located at .wundergraph/operations/users/get.ts
, so the route of the operation is /operations/users/get
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Let's call this operation using curl:
1
The result should be:
1
2
3
4
5
6
7