Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to the pre-route plugin docs #874

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/plugins/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Pre-response plugins are triggered at the final stage of the execution pipeline,
before the response is sent to the client**. These plugins allow you to execute logic based on the response such as
calling third-party services before the client receives the response.

### Pre-Route plugins

Pre-route plugins are executed at the very beginning of the request handling (for other than pre-defined endpoints).
This allows you to add custom HTTP handlers to your API. You can use these plugins to add RESTified GraphQL endpoints or
internal tools like GraphQL schema visualizers, Swagger UI for JSON API, etc.
robertjdominguez marked this conversation as resolved.
Show resolved Hide resolved

## Find out more

- [Learn more about how plugins work](/plugins/introduction.mdx)
Expand Down
18 changes: 16 additions & 2 deletions docs/plugins/restified-endpoints/how-to.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ definition:
url:
valueFromEnv: RESTIFIED_ENDPOINTS_URL
config:
match: "/v1/api/rest/*"
matchPath: "/v1/api/rest/*"
matchMethods: ["GET", "POST"]
request:
method: GET
headers:
forward:
- Authorization
- x-hasura-role
- x-hasura-ddn-token
additional:
hasura-m-auth:
valueFromEnv: M_AUTH_KEY
Expand All @@ -87,6 +88,11 @@ definition:
query: {}
method: {}
body: {}
response:
headers:
additional:
content-type:
value: application/json
```

:::tip URL Match
Expand Down Expand Up @@ -167,7 +173,6 @@ Update the `src/config.ts` file with the RESTified GraphQL endpoints that you wa
```typescript
export const Config = {
graphqlServer: {
url: "http://localhost:3000/graphql",
headers: {
additional: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -218,11 +223,15 @@ In `restified-endpoints-plugin` directory, update the `wrangler.toml` file with
[vars]
OTEL_EXPORTER_OTLP_ENDPOINT = "https://gateway.otlp.hasura.io:443/v1/traces"
OTEL_EXPORTER_PAT = "<PAT>"
GRAPHQL_SERVER_URL = "<DDN_GRAPHQL_SERVER_URL>"
```

Replace `<PAT>` with the Personal Access Token (PAT) for the Hasura Cloud account. You can display this using the
`ddn auth print-pat` command.

Replace `<DDN_GRAPHQL_SERVER_URL>` with the URL of your DDN GraphQL server. You can find this in the DDN console under
the `Settings > Project Summary` section.

## Step 7. Deploy the plugin

For your plugin to be reachable by your hosted supergraph, we'll need to deploy using Cloudflare Wrangler. The `deploy`
Expand Down Expand Up @@ -250,4 +259,9 @@ Create a new supergraph build on Hasura DDN to check your work in the cloud.
ddn supergraph build create
```

## Step 9. Apply the build

Apply the build to make it the default one served by your Hasura DDN project endpoint. You can do this from the DDN
console by choosing the build from the `Builds` tab and clicking `Apply Build`.

The engine will execute the plugin for each requests to the RESTified GraphQL endpoints you defined.
Loading