New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@urql/exchange-execute

Package Overview
Dependencies
Maintainers
0
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@urql/exchange-execute

An exchange for executing queries against a local schema in urql

  • 2.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.8K
increased by3.59%
Maintainers
0
Weekly downloads
 
Created
Source

@urql/exchange-execute

An exchange for executing queries against a local schema in urql

@urql/exchange-execute is an exchange for the 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:

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:

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 provided by graphql-js.

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

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,
}),
// ...

Keywords

FAQs

Package last updated on 03 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc