However, sometimes you want to build something fully custom, or you want to wrap the functionality of an existing API with custom logic. This is what TypeScript Operations are for.
What are TypeScript Operations?
TypeScript Operations are also defined in the
.wundergraph/operations directory, and they share the same features as GraphQL Operations, like you can configure authentication, authorization, caching, input validation, etc...
TypeScript Operations can also be called exactly the same way as GraphQL Operations. They are being added to the router of your WunderGraph Application, and you can call them from your generated clients the same way as you would call a GraphQL Operation.
How do I use TypeScript Operations?
TypeScript Operations come in three different flavors, similar to GraphQL Operations:
Here's a typical file structure when using TypeScript Operations:
With this API, we're able to get, create, update, delete and subscribe to users.
Creating TypeScript Read Operations (Query)
Let's define the four operations, starting with the
Creating TypeScript Write Operations (Mutation)
Next, let's define the
Now, let's implement the
Creating TypeScript Subscribe Operations
Finally, let's implement the
How do I use TypeScript Operations in my client?
How do I use my TypeScript Operations using plain HTTP, e.g. using curl