Skip to main content
The Request Bridge API allows you to manually register network requests with Limelight. This is useful when your app makes requests through channels that Limelight can’t automatically intercept, such as native modules.

When to use this

Limelight automatically captures requests made through fetch and XMLHttpRequest. However, some apps route network traffic through other channels:
  • Native network modules - Custom native modules that handle HTTP requests at the iOS/Android layer
  • Custom Apollo Links - Apollo Client configurations that bypass fetch entirely
  • WebSocket-based transports - GraphQL subscriptions or custom protocols
  • Third-party SDKs - Libraries with their own networking stack
If your requests aren’t showing up in Limelight, the Request Bridge lets you manually report them.

Basic usage

import { Limelight } from "@getlimelight/sdk";

// 1. Start tracking before making the request
const requestId = Limelight.startRequest({
  url: "https://api.example.com/graphql",
  method: "POST",
});

// 2. Make your request however you normally would
const response = await myNativeModule.makeRequest(/* ... */);

// 3. Report the response back to Limelight
Limelight.endRequest(requestId, {
  status: 200,
  body: response,
});

GraphQL requests

For GraphQL operations, include the graphql config to get full query analysis in Limelight:
const requestId = Limelight.startRequest({
  url: "https://api.example.com/graphql",
  method: "POST",
  graphql: {
    operationName: "GetUser",
    operationType: "query",
    variables: { id: "123" },
    query: `
      query GetUser($id: ID!) {
        user(id: $id) {
          id
          name
          email
        }
      }
    `,
  },
});

Apollo Client integration

If you’re using Apollo Client with a custom link that bypasses fetch, create a Limelight link:
import { ApolloLink, Observable } from "@apollo/client";
import { Limelight } from "@getlimelight/sdk";
import { Kind } from "graphql";

const GRAPHQL_ENDPOINT = "https://api.example.com/graphql";

export const limelightLink = new ApolloLink((operation, forward) => {
  const operationType = operation.query.definitions.find(
    (def) => def.kind === Kind.OPERATION_DEFINITION,
  )?.operation;

  const requestId = Limelight.startRequest({
    url: GRAPHQL_ENDPOINT,
    method: "POST",
    graphql: {
      operationName: operation.operationName,
      operationType,
      variables: operation.variables,
      query: operation.query.loc?.source.body,
    },
  });

  return new Observable((observer) => {
    const subscription = forward(operation).subscribe({
      next: (response) => {
        Limelight.endRequest(requestId, {
          status: 200,
          body: response,
        });
        observer.next(response);
      },
      error: (error) => {
        Limelight.failRequest(requestId, error);
        observer.error(error);
      },
      complete: () => observer.complete(),
    });

    return () => subscription.unsubscribe();
  });
});
Add the link to your Apollo Client:
import { ApolloClient, InMemoryCache, ApolloLink } from "@apollo/client";

const client = new ApolloClient({
  link: ApolloLink.from([
    limelightLink,
    yourNativeLink, // Your custom link that uses native modules
  ]),
  cache: new InMemoryCache(),
});

Handling errors

Use failRequest when a request fails:
const requestId = Limelight.startRequest({
  url: "https://api.example.com/data",
  method: "GET",
});

try {
  const response = await myNativeModule.makeRequest(/* ... */);
  Limelight.endRequest(requestId, {
    status: response.status,
    body: response.data,
  });
} catch (error) {
  Limelight.failRequest(requestId, error);
}

API reference

Limelight.startRequest(config)

Starts tracking a request. Call this before making the actual network request. Parameters:
NameTypeRequiredDescription
urlstringYesThe request URL
methodstringNoHTTP method (defaults to POST)
headersRecord<string, string>NoRequest headers
bodyanyNoRequest body
namestringNoCustom display name
graphqlobjectNoGraphQL operation details
graphql.operationNamestringNoOperation name
graphql.operationType"query" | "mutation" | "subscription"NoOperation type
graphql.variablesobjectNoOperation variables
graphql.querystringNoQuery string
Returns: string - A request ID to use with endRequest or failRequest.

Limelight.endRequest(requestId, response)

Completes a tracked request with a successful response. Parameters:
NameTypeRequiredDescription
requestIdstringYesThe ID returned from startRequest
response.statusnumberYesHTTP status code
response.statusTextstringNoHTTP status text
response.headersRecord<string, string>NoResponse headers
response.bodyanyNoResponse body

Limelight.failRequest(requestId, error)

Completes a tracked request with an error. Parameters:
NameTypeRequiredDescription
requestIdstringYesThe ID returned from startRequest
errorError | stringYesThe error that occurred