pub struct DegraphqlPlugin {
query: String,
variables: Vec<String>,
operation_name: Option<String>,
}Expand description
Rewrites the request into a GraphQL POST for the configured query.
Only GET and POST requests are accepted (anything else exits through
the error port with a 405 and code METHOD_NOT_ALLOWED, mirroring
APISIX). Each configured variable name is looked up in the request’s
query parameters (first value, as a string) and then in the JSON request
body (any JSON type); names found in neither are omitted from
variables. A non-empty request body that is not valid JSON fails with
a 400 and code INVALID_REQUEST_BODY when body lookups are needed.
Fields§
§query: String§variables: Vec<String>§operation_name: Option<String>Implementations§
Source§impl DegraphqlPlugin
impl DegraphqlPlugin
Sourcepub fn from_config(config: &HashMap<String, Value>) -> Result<Self, String>
pub fn from_config(config: &HashMap<String, Value>) -> Result<Self, String>
Builds the plugin from node config.
Accepted keys:
query(string, required, 1–1024 chars): the GraphQL document sent upstream. Checked structurally at config load (balanced braces, a selection set present).variables(array of strings, optional): variable names to collect from the request. When present it must be non-empty. When absent, novariableskey is sent upstream.operation_name(string, optional, 1–1024 chars): sent asoperationNamefor multi-operation documents.
type: degraphql
config:
query: |
query ($name: String!) {
persons(filter: { name: $name }) { id name }
}
variables: [name]Trait Implementations§
Source§impl Plugin for DegraphqlPlugin
impl Plugin for DegraphqlPlugin
Source§fn plugin_type(&self) -> &str
fn plugin_type(&self) -> &str
Unique identifier for the plugin type (e.g., “proxy-rewrite”, “upstream”).
Source§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Context,
_named_inputs: &'life1 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<PluginOutput, PluginExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Context,
_named_inputs: &'life1 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<PluginOutput, PluginExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Executes the plugin logic against the request/response context. Read more
Auto Trait Implementations§
impl Freeze for DegraphqlPlugin
impl RefUnwindSafe for DegraphqlPlugin
impl Send for DegraphqlPlugin
impl Sync for DegraphqlPlugin
impl Unpin for DegraphqlPlugin
impl UnsafeUnpin for DegraphqlPlugin
impl UnwindSafe for DegraphqlPlugin
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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