# @urql/exchange-execute

> An exchange for executing queries against a local schema in urql

Latest version **3.0.0** (published 2025-08-09) · MIT license · 10.9K weekly downloads

## Install

```sh
npm install @urql/exchange-execute
pnpm add @urql/exchange-execute
yarn add @urql/exchange-execute
bun add @urql/exchange-execute
```

## Health

**Score 70/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2025-08-09 |
| First published | 2020-05-07 |
| Weekly downloads | 10.9K |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 30 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 8975 |
| Author | urql GraphQL Contributors |
| Maintainers | michaelmerrill, sarmeyer, mariano-formidable, ryan.roemer, formidable-owner, formidablelabs, carbonrobot, masiddee, scott-rippey, sarahformidable, robwalkerco, ceceppa, keithluchtel, scottianstewart, philpl, andyrichardson, jdecroock, parkerziegler, npm-urql |
| Keywords | urql, exchange, execute, executable schema, graphql, exchanges |

## Links

- npm: https://www.npmjs.com/package/@urql/exchange-execute
- Repository: https://github.com/urql-graphql/urql
- Homepage: https://formidable.com/open-source/urql/docs/
- Issues: https://github.com/urql-graphql/urql/issues
- npm.io page: https://npm.io/package/@urql/exchange-execute

## Dependencies (2)

- [wonka](https://npm.io/package/wonka.md) ^6.3.2
- [@urql/core](https://npm.io/package/@urql/core.md) ^6.0.0

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2025-08-09
- 3.0.0-canary-b981b388ee9ed0066399a632aad6b84559f014a6 (canary) — 2025-08-09
- 1.1.0-defer.0 (defer) — 2021-08-12
- 3.0.0-canary-d3b019d51905c1c8b22be9ea1d9fe9ca4335a46c — 2025-08-09
- 3.0.0-canary-b2d8b993af4abb0ffc5c5284b90aca56c527f045 — 2025-06-29
- 2.3.1 — 2025-03-03
- 2.3.1-canary-573944cea80f766668d3b9d8aa1afd2c50d744a4 — 2025-03-03
- 2.3.0 — 2024-05-10
- 2.3.0-canary-9bf3289b — 2024-05-07
- 2.3.0-canary-019b1bb0 — 2024-05-04
- 2.3.0-canary-9272cefa — 2024-05-03
- 2.3.0-canary-0204e044 — 2024-05-03
- 2.2.2 — 2023-05-31
- 0.0.0-canary-20230531112256 — 2023-05-31
- 0.0.0-canary-20230531101109 — 2023-05-31
- … 58 more at https://npm.io/package/@urql/exchange-execute/versions

## README

<h2 align="center">@urql/exchange-execute</h2>

<p align="center"><strong>An exchange for executing queries against a local schema in <code>urql</code></strong></p>

`@urql/exchange-execute` is an exchange for the [`urql`](https://github.com/urql-graphql/urql) GraphQL client which executes queries against a local schema.
This is a replacement for the default _fetchExchange_ which sends queries over HTTP/S to be executed remotely.

## Quick Start Guide

First install `@urql/exchange-execute` alongside `urql`:

```sh
yarn add @urql/exchange-execute
# or
npm install --save @urql/exchange-execute
```

You'll then need to add the `executeExchange`, that this package exposes, to your `urql` Client,
by replacing the default fetch exchange with it:

```js
import { createClient, cacheExchange } from 'urql';
import { executeExchange } from '@urql/exchange-execute';

const client = createClient({
  url: 'http://localhost:1234/graphql',
  exchanges: [
    cacheExchange,
    // Replace the default fetchExchange with the new one.
    executeExchange({
      /* config */
    }),
  ],
});
```

## Usage

The exchange takes the same arguments as the [_execute_ function](https://graphql.org/graphql-js/execution/#execute) provided by graphql-js.

Here's a brief example of how it might be used:

```js
import { buildSchema } from 'graphql';

// Create local schema
const schema = buildSchema(`
  type Todo {
    id: ID!
    text: String!
  }

  type Query {
    todos: [Todo]!
  }

  type Mutation {
    addTodo(text: String!): Todo!
  }
`);

// Create local state
let todos = [];

// Create root value with resolvers
const rootValue = {
  todos: () => todos,
  addTodo: (_, args) => {
    const todo = { id: todos.length.toString(), ...args };
    todos = [...todos, todo];
    return todo;
  }
}

// ...

// Pass schema and root value to executeExchange
executeExchange({
  schema,
  rootValue,
}),
// ...
```

---
_Source: https://npm.io/package/@urql/exchange-execute · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
