pub struct GraphqlClient { /* private fields */ }Expand description
A cloneable client for the project’s graphql/v1 endpoint.
Implementations§
Source§impl GraphqlClient
impl GraphqlClient
Sourcepub fn new(project_url: &Url, api_key: &str) -> Result<Self, GraphqlClientError>
pub fn new(project_url: &Url, api_key: &str) -> Result<Self, GraphqlClientError>
Create a same-origin-redirect-only HTTP client. Legacy keys also supply a bearer token; new publishable/secret keys do not.
§Errors
Returns invalid URL, credential-header, or HTTP client construction errors.
Sourcepub fn new_with_client(
project_url: &Url,
api_key: &str,
http: Client,
) -> Result<Self, GraphqlClientError>
pub fn new_with_client( project_url: &Url, api_key: &str, http: Client, ) -> Result<Self, GraphqlClientError>
Use an existing HTTP client without changing its TLS or redirect configuration.
§Errors
Returns invalid URL or credential-header errors.
Sourcepub fn with_access_token(&self, token: &str) -> Result<Self, GraphqlClientError>
pub fn with_access_token(&self, token: &str) -> Result<Self, GraphqlClientError>
Clone the client with a user’s bearer token, preserving its retry policy.
§Errors
Returns an error if the token is not a valid header value.
Sourcepub const fn with_retry_policy(self, policy: RetryPolicy) -> Self
pub const fn with_retry_policy(self, policy: RetryPolicy) -> Self
Configure 429 retries. POST requests are never replayed unless explicitly opted in.
Sourcepub fn query(&self, document: &str) -> QueryBuilder
pub fn query(&self, document: &str) -> QueryBuilder
Start a POST request. Documents and variables are omitted from builder debug output.
Trait Implementations§
Source§impl Clone for GraphqlClient
impl Clone for GraphqlClient
Auto Trait Implementations§
impl !RefUnwindSafe for GraphqlClient
impl !UnwindSafe for GraphqlClient
impl Freeze for GraphqlClient
impl Send for GraphqlClient
impl Sync for GraphqlClient
impl Unpin for GraphqlClient
impl UnsafeUnpin for GraphqlClient
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