Skip to main content

Getting Started with Tailcall Directives

Tailcall DSL builds on your existing GraphQL knowledge by allowing the addition of some custom directives. These directives provide powerful compile time guarantees to ensure your API composition is tight and robust. Behind the scenes, Tailcall automatically generates highly optimized resolver logic for your types using the information in the directives.

Here is a list of all the custom directives supported by Tailcall:

OperatorDescription
@addFieldSimplifies data structures and queries by adding, inlining, or flattening fields or nodes within the schema.
@cacheEnables caching for the query, field or type applied to.
@callInvokes a query or mutation from another query or mutation field.
@discriminateAllows to customize the discriminator while working with union types.
@exprAllows embedding of a constant response within the schema.
@graphQLResolves a field or node by a GraphQL API.
@grpcResolves a field or node by a gRPC API.
@httpResolves a field or node by a REST API.
@linkImports external resources such as config files, certs, protobufs, etc in the schema.
@modifyEnables changes to attributes of fields or nodes in the schema.
@omitExcludes fields or nodes from the generated schema, making them inaccessible through the GraphQL API.
@protectedAdds authentication and authorization controls to fields or nodes in the schema.
@restAllows exposing REST endpoints on top of GraphQL.
@serverProvides server configurations for behavior tuning and tailcall optimization in specific use-cases.
@telemetryIntegrates with open-telemetry to provide observability of the running tailcall service.
@upstreamControls aspects of the upstream server connection, including timeouts and keep-alive settings.