-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: add link operator * fix: add minor change * fix: prettier and write-good * fix: add changes * fix: backlink path * chore: prettier * fix: backlink path for real * update link * update note --------- Co-authored-by: Tushar Mathur <[email protected]>
- Loading branch information
1 parent
84b452d
commit d9fabd6
Showing
3 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
title: "@link" | ||
--- | ||
|
||
The **@link** operator is used for bringing external resources into your GraphQL schema. It makes it easier to include configurations, .proto files for gRPC services, and other files into your schema. With this operator, external resources are either merged with or used effectively in the importing configuration. | ||
|
||
## How it Works | ||
|
||
The `@link` directive requires specifying a source `src`, the resource's type `type`, and an optional identifier `id`. | ||
|
||
- `src`: The source of the link is defined here. It can be either a URL or a file path. When a file path is given, it's relative to the file's location that is importing the link. | ||
|
||
- `type`: This specifies the link's type, which determines how the imported resource is integrated into the schema. For a list of supported types, see the [Supported Types](#supported-types) section. | ||
|
||
- `id`: This is an optional field that assigns a unique identifier to the link. It's helpful for referring to the link within the schema. | ||
|
||
## Example | ||
|
||
The following example illustrates how to utilize the `@link` directive to incorporate a Protocol Buffers (.proto) file for a gRPC service into your GraphQL schema. | ||
|
||
```graphql showLineNumbers | ||
schema | ||
@server(port: 8000, graphiql: true) | ||
@upstream(baseURL: "http://news.local", httpCache: true, batch: {delay: 10}) | ||
@link(id: "news", src: "../src/grpc/news.proto", type: Protobuf) { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
news: NewsData! @grpc(method: "news.NewsService.GetAllNews") | ||
} | ||
|
||
type News { | ||
id: Int | ||
title: String | ||
body: String | ||
postImage: String | ||
} | ||
|
||
type NewsData { | ||
news: [News]! | ||
} | ||
``` | ||
|
||
## Supported Types | ||
|
||
The `@link` directive supports the following types of links: | ||
|
||
- `Config`: Imports a schema configuration file. During the merge, settings from the imported file override those in the main schema for any overlaps, facilitating a modular and scalable approach to schema configuration. The operation is morally equivalent to tailcall's [compose](/docs/guides/cli.md#compose) command. | ||
|
||
- `Protobuf`: Imports a .proto file for gRPC services. This type facilitates the integration of gRPC services into your GraphQL schema by allowing the inclusion of Protocol Buffers definitions. It enables the GraphQL server to communicate with gRPC services directly. For integrating gRPC services, refer to [gRPC Integration Guide](/docs/guides/grpc.md). | ||
|
||
- `Script`: A link to an external JavaScript file that listens on every HTTP request response event. This allows for the execution of custom logic or filters based on the request and response. Example usage: | ||
|
||
```javascript showLineNumbers | ||
function onRequest({request}) { | ||
// Add a custom header for all outgoing responses | ||
request.headers["X-Custom-Header"] = "Processed" | ||
|
||
// Return the updated request | ||
return {request} | ||
} | ||
``` | ||
|
||
- `Cert`: Imports a SSL/TLS certificate for HTTPS. | ||
- `Key`: Imports a SSL/TLS private key for HTTPS. | ||
|
||
Each type serves a specific purpose, enabling the flexible integration of external resources into your GraphQL schema. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,9 @@ const Hello = (): JSX.Element => { | |
if (!isValid) setIsValid(true) | ||
}} | ||
className={`border border-solid border-tailCall-border-light-500 rounded-lg font-space-grotesk h-11 w-[95%] sm:w-[480px] | ||
p-SPACE_03 text-content-small outline-none focus:border-x-tailCall-light-700 ${isValid ? "is-valid" : "is-invalid"}`} | ||
p-SPACE_03 text-content-small outline-none focus:border-x-tailCall-light-700 ${ | ||
isValid ? "is-valid" : "is-invalid" | ||
}`} | ||
placeholder="[email protected]" | ||
/> | ||
{!isValid && <div className="text-red-400">Please enter a valid email.</div>} | ||
|