Skip to content

Commit

Permalink
docs: omit operator (tailcallhq#115)
Browse files Browse the repository at this point in the history
* docs: omit operator

* fix: add changes

* chore: run prettier

* fix: add changes

* update title

* fix: add backlink to modify

* fix: typo

---------

Co-authored-by: Tushar Mathur <[email protected]>
  • Loading branch information
neo773 and tusharmath authored Feb 28, 2024
1 parent ce4af35 commit f9818f2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/operators/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ Certainly! Here's the table with hyperlinks added back to the operator names:
| [@grpc](grpc.md) | Resolves a field or node by a gRPC API. |
| [@http](http.md) | Resolves a field or node by a REST API. |
| [@modify](modify.md) | Enables changes to attributes of fields or nodes in the schema. |
| [@omit](omit.md) | Excludes fields or nodes from the generated schema, making them inaccessible through the GraphQL API. |
| [@server](server.md) | Provides server configurations for behavior tuning and tailcall optimization in specific use-cases. |
| [@upstream](upstream.md) | Controls aspects of the upstream server connection, including timeouts and keep-alive settings. |
4 changes: 4 additions & 0 deletions docs/operators/modify.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ type User {
```

`@modify(omit: true)` instructs GraphQL to exclude the `id` field from the schema, making it inaccessible to the client.

:::tip
**@omit** is a standalone operator and is an alias/shorthand for `modify(omit: true)` checkout [documentation](/docs/operators/omit)
:::
37 changes: 37 additions & 0 deletions docs/operators/omit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "@omit"
---

Within a GraphQL schema, the **@omit** operator excludes fields or nodes from the generated schema, making them inaccessible through the GraphQL API. This operator is useful for hiding sensitive information or simplifying your API by removing unnecessary fields.

## How it works

When applied to a field or node, the **@omit** operator instructs the Tailcall not to include that field or node in the schema. This means that clients cannot query or mutate data in those fields.

## Example

Consider a scenario where you have a `User` type with an embedded `Address` type. If you want to exclude the `Address` type from the schema to simplify the API, you can use the **@omit** operator:

```graphql showLineNumbers
type Address {
city: String
street: String
}

type User {
name: String
address: Address @omit
}
```

In this example, the `address` field will not be accessible or visible through the GraphQL API.

## Comparison with `modify`

The **@omit** operator and `@modify(omit: true)` essentially serve the same purpose in excluding fields from the schema, but they differ in syntax and flexibility. In fact, one can consider **@omit** as a shorthand or alias for the more verbose `@modify(omit: true)`.

- **@omit** offers a concise way to directly exclude a field or node without additional arguments.

- `@modify(omit: true)`, as part of the broader **@modify** operator, provides more options, such as field renaming through the `name` argument. This makes it a more flexible choice when you need more than field exclusion.

For more details on the **@modify** operator and its capabilities, including omitting fields, see the [@modify documentation](/docs/operators/modify#omit).

0 comments on commit f9818f2

Please sign in to comment.