pub struct Client {
pub http_client: Client,
pub subgraph_url: Url,
pub auth_token: Option<String>,
/* private fields */
}
Expand description
A client for interacting with a subgraph.
Fields§
§http_client: Client
§subgraph_url: Url
§auth_token: Option<String>
The request authentication bearer token.
This is token is inserted in the Authentication
header.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(http_client: Client, subgraph_url: Url) -> Self
pub fn new(http_client: Client, subgraph_url: Url) -> Self
Create a new client with default settings.
The default settings are:
- No authentication token
- Latest block number of 0
Sourcepub fn builder(http_client: Client, subgraph_url: Url) -> ClientBuilder
pub fn builder(http_client: Client, subgraph_url: Url) -> ClientBuilder
Create a new client builder.
The builder allows for configuring the client before building it.
Example:
let client = SubgraphClient::builder(http_client, subgraph_url)
.with_auth_token(Some(auth))
.with_subgraph_latest_block(18627000)
.build();
Sourcepub async fn query<T>(
&self,
query: impl IntoRequestParameters + Send,
) -> Result<T, String>where
T: for<'de> Deserialize<'de>,
pub async fn query<T>(
&self,
query: impl IntoRequestParameters + Send,
) -> Result<T, String>where
T: for<'de> Deserialize<'de>,
Send a query to the subgraph.
Sourcepub async fn paginated_query<T>(
&self,
query: impl IntoDocument + Clone,
page_size: usize,
) -> Result<Vec<T>, PaginatedQueryError>where
T: for<'de> Deserialize<'de>,
pub async fn paginated_query<T>(
&self,
query: impl IntoDocument + Clone,
page_size: usize,
) -> Result<Vec<T>, PaginatedQueryError>where
T: for<'de> Deserialize<'de>,
Send a paginated query to the subgraph.
The query is sent with a page size of page_size
and the latest block number that the
subgraph has progressed to.
In the case of a reorg, the function will return an error.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more