sui_graphql_rpc_client/
lib.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use async_graphql::Value;
5use reqwest::header::ToStrError;
6use serde_json::Number;
7
8pub mod response;
9pub mod simple_client;
10
11#[derive(Debug, thiserror::Error)]
12pub enum ClientError {
13    #[error("Service version header not found")]
14    ServiceVersionHeaderNotFound,
15    #[error("Service version header value invalid string: {error}")]
16    ServiceVersionHeaderValueInvalidString { error: ToStrError },
17    #[error("Invalid usage number for {usage_name}: {usage_number}")]
18    InvalidUsageNumber {
19        usage_name: String,
20        usage_number: Number,
21    },
22    #[error("Invalid usage field for {usage_name}: {usage_value}")]
23    InvalidUsageValue {
24        usage_name: String,
25        usage_value: Value,
26    },
27    #[error("{item_type} at pos {idx} must not be empty")]
28    InvalidEmptyItem { item_type: String, idx: usize },
29    #[error(
30        "Invalid variable name: `{var_name}`. Variable names must be non-empty and start with a letter or underscore, and may only contain letters, digits, and underscores."
31    )]
32    InvalidVariableName { var_name: String },
33
34    #[error(
35        "Conflicting type definitions for variable {var_name}: {var_type_prev} vs {var_type_curr}"
36    )]
37    VariableDefinitionConflict {
38        var_name: String,
39        var_type_prev: String,
40        var_type_curr: String,
41    },
42    #[error("Conflicting values for variable {var_name}: {var_val_prev} vs {var_val_curr}")]
43    VariableValueConflict {
44        var_name: String,
45        var_val_prev: serde_json::Value,
46        var_val_curr: serde_json::Value,
47    },
48    #[error(transparent)]
49    InnerClientError(#[from] reqwest::Error),
50}