0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

URQL の devtool を Chrome で動かす

0
Posted at

概要

GraphQL クライアントライブラリの一種である URQL でも devtool を導入し、クエリ結果及びキャッシュの状態を確認できるようにする。

バージョン情報

  • urql 3.0.3
  • urql-devtools 2.6.3
  • @urql/devtools 2.0.3
  • Google Chrome 106

前提

urql はインストール済みで既に使用中であることを前提とする。

手順

Chrome 拡張をインストール

devtool 用の exchange (urql におけるミドルウェアやプラグインのようなもの) をインストール

# npm
npm i @urql/devtools

# yarn
yarn add @urql/devtools

クライアントセットアップ時に exchange をインストール。 (デフォルトの exchange を上書きしないようにする)

import { createClient, defaultExchanges } from 'urql'
import { devtoolsExchange } from '@urql/devtools'

const urqlClient = createClient({
  url: '/api/graphql',
  exchanges: [devtoolsExchange, ...defaultExchanges]
})

Chrome を開いて、 Urql タブを開くと devtool が動いてるのが確認できる。

スクリーンショット 2022-11-10 18.55.18.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?