Skip to content

Commit

Permalink
Merge main into release-stage
Browse files Browse the repository at this point in the history
  • Loading branch information
hasura-bot committed Feb 7, 2025
2 parents 61bf3ca + 9e34bd5 commit 1516207
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/plugins/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ 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 request handling, **before predefined endpoints are processed**. They allow you to insert custom HTTP handlers into your API, enabling features like REST-style GraphQL endpoints, internal tools, or documentation interfaces such as a GraphQL schema visualizer or Swagger UI for a JSON API.

## 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-access-token` 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.

0 comments on commit 1516207

Please sign in to comment.