Skip to Content
Octopus Energy Packages

Overview

Typed GraphQL requests and an HTTP relay for Kraken applications

@octopus-energy/graphql provides a small, typed Fetch client and a server-side relay for GraphQL APIs such as Kraken.

Installation

npm i @octopus-energy/graphql
RequirementVersion
Node.js≥24.0.0

Why we built it

@krakentech/blueprint-auth combines Kraken authentication with a GraphQL client and a handler that forwards browser requests to Kraken. The upcoming @octopus-energy/better-auth package focuses on authentication, so apps migrating to it also need a GraphQL layer.

This package provides that layer. createGraphQLHandler replaces Blueprint Auth’s GraphQL handler, and @octopus-energy/better-auth provides the krakenRequestAuth integration to resolve credentials and attach upstream headers.

A server route lets the browser call Kraken using credentials stored in encrypted HTTP-only cookies. The server reads the session and supplies the upstream authorization header. Same-origin requests can also avoid restrictions that ad blockers and security extensions apply to third-party requests, although behavior varies by extension and configuration.

The request client infers variable and result types from documents produced by gql.tada or GraphQL Code Generator. It also keeps the browser bundle small. See Compare clients for measurements.

How it fits into your app

In server code, use createGraphQLRequest to call the upstream API directly. Pass the current user’s authorization header with each call. The client infers variable and result types from typed documents.

In the browser, use createGraphQLRequest with the URL of a same-origin route in your application. createGraphQLHandler runs on your server, attaches the credentials supplied by your authentication integration, and forwards the request to the upstream API. The response returns through that route to the browser.

Adopt the client independently

Apps using Blueprint Auth can keep their existing GraphQL route while switching client calls. See From Blueprint Auth for examples.

Choose a factory

On this page