grafbase_hooks/hooks/
subgraph.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::wit::HttpMethod;

/// A structure representing a request that will be sent to a subgraph.
pub struct SubgraphRequest {
    subgraph_name: String,
    method: HttpMethod,
    url: String,
}

impl SubgraphRequest {
    pub(crate) fn new(subgraph_name: String, method: HttpMethod, url: String) -> Self {
        Self {
            subgraph_name,
            method,
            url,
        }
    }

    /// Returns the name of the subgraph.
    pub fn subgraph_name(&self) -> &str {
        &self.subgraph_name
    }

    /// Returns the URl for this request.
    pub fn url(&self) -> &str {
        &self.url
    }

    /// Returns the HTTP method for this request.
    pub fn method(&self) -> HttpMethod {
        self.method
    }
}