pub struct GraphqlClient { /* private fields */ }Expand description
HTTP client for the Supabase GraphQL endpoint (/graphql/v1).
Provides both raw query execution and fluent builder methods for collection queries and mutations.
§Example
ⓘ
use supabase_client_graphql::GraphqlClient;
let client = GraphqlClient::new("https://your-project.supabase.co", "your-anon-key")?;
// Raw query
let response = client.execute("query { blogCollection { edges { node { id } } } }", None, None).await?;
// Builder API
let connection = client.collection("blogCollection")
.select(&["id", "title"])
.first(10)
.execute::<BlogRow>().await?;Implementations§
Source§impl GraphqlClient
impl GraphqlClient
Sourcepub fn new(supabase_url: &str, api_key: &str) -> Result<Self, GraphqlError>
pub fn new(supabase_url: &str, api_key: &str) -> Result<Self, GraphqlError>
Create a new GraphQL client.
supabase_url is the project URL (e.g., https://your-project.supabase.co).
api_key is the Supabase anon or service_role key.
Sourcepub fn set_auth(&self, token: &str)
pub fn set_auth(&self, token: &str)
Update the default auth token for GraphQL requests.
Subsequent requests will use Bearer <token> instead of the API key.
Sourcepub async fn execute<T: DeserializeOwned>(
&self,
query: &str,
variables: Option<Value>,
operation_name: Option<&str>,
) -> Result<GraphqlResponse<T>, GraphqlError>
pub async fn execute<T: DeserializeOwned>( &self, query: &str, variables: Option<Value>, operation_name: Option<&str>, ) -> Result<GraphqlResponse<T>, GraphqlError>
Sourcepub async fn execute_raw(
&self,
query: &str,
variables: Option<Value>,
operation_name: Option<&str>,
) -> Result<GraphqlResponse<Value>, GraphqlError>
pub async fn execute_raw( &self, query: &str, variables: Option<Value>, operation_name: Option<&str>, ) -> Result<GraphqlResponse<Value>, GraphqlError>
Execute a raw GraphQL query and return the full data JSON value.
This is a convenience wrapper around execute that returns
the data as an untyped serde_json::Value.
Sourcepub fn collection(&self, name: &str) -> QueryBuilder
pub fn collection(&self, name: &str) -> QueryBuilder
Sourcepub fn insert_into(&self, collection: &str) -> MutationBuilder
pub fn insert_into(&self, collection: &str) -> MutationBuilder
Sourcepub fn update(&self, collection: &str) -> MutationBuilder
pub fn update(&self, collection: &str) -> MutationBuilder
Sourcepub fn delete_from(&self, collection: &str) -> MutationBuilder
pub fn delete_from(&self, collection: &str) -> MutationBuilder
Trait Implementations§
Source§impl Clone for GraphqlClient
impl Clone for GraphqlClient
Source§fn clone(&self) -> GraphqlClient
fn clone(&self) -> GraphqlClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GraphqlClient
impl !RefUnwindSafe for GraphqlClient
impl Send for GraphqlClient
impl Sync for GraphqlClient
impl Unpin for GraphqlClient
impl UnsafeUnpin for GraphqlClient
impl !UnwindSafe 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