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?

【React】urqlをv5にアップデートしたらGraphqlのクエリがGET通信になった

Posted at

概要

2025年8月に、GraphQLのクライアントライブラリであるurqlがv5にアップデートされました。
私の個人開発してるWebアプリでもurqlを使用しておりアップデートをしてみたのですが、アップデートしたらGraphqlのクエリがGET通信になってしまいました。ここら辺の仕様変更や対応等についてメモ書きします。

前提

  • 使用したurqlのバージョンは5.0.1です。

仕様変更について

major(core|persisted): use GET for queries by defaultのPull Requestsを確認すると、preferGetMethodの設定値がwithin-url-limitでデフォルト設定になったようです。Clientのドキュメントによると、within-url-limitではURLの文字数が規定以内であればGETを使うみたいな挙動になるようです。

GETを使用したくない時

とはいえ、サーバサイド側ではPOSTで統一したいケースもあると思いますので、GETは使いたくないという時もあるでしょう。その際はclientの設定で、以下の通りpreferGetMethodをfalseにすれば大丈夫です。

const graphqlClient = createClient({
    url: `${process.env.API_URL}`,
    exchanges: [cacheExchange, fetchExchange],
    preferGetMethod: false,
  });
};

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?