Open7
(クライアント側での)GraphQL 学習スレ
GraphQLの使い方をPlaygroundに沿って、この記事を通して学習
Playgroundで一番気軽かつ便利そうなこれを試す
クエリ、スキームを読み取ってドキュメント化してくれるので便利
使うパッケージはこれ
エラーハンドリング
こいつを使ったリクエストする際のエラーハンドリング
タイムアウトやインターネット接続失敗
/// Exception occurring when network fails
/// or parsed response is missing both `data` and `errors`
class ServerException extends LinkException {
/// The parsed response
final Response? parsedResponse;
const ServerException({
this.parsedResponse,
dynamic originalException,
}) : super(originalException);
String toString() =>
"ServerException(originalException: $originalException, parsedResponse: $parsedResponse)";
}
200系以外(厳密には300以上になってる)のエラーハンドリングは多分これ投げてくれる
/// Exception occurring when network fails
/// or parsed response is missing both `data` and `errors`.
class HttpLinkServerException extends ServerException {
/// Response which caused the exception
final http.Response response;
const HttpLinkServerException({
required this.response,
required Response parsedResponse,
}) : super(
parsedResponse: parsedResponse,
);
}
ちょっと参考にしたもの
よくあるGraphQLクライアントの使い方がどんなものかを参考にした資料