Merge pull request #508 from oscartbeaumont/master
Allow the ability to set GraphQL Playground settings
This commit is contained in:
commit
8152f5f867
|
@ -564,6 +564,7 @@ pub struct GraphQLPlaygroundConfig<'a> {
|
|||
endpoint: &'a str,
|
||||
subscription_endpoint: Option<&'a str>,
|
||||
headers: Option<HashMap<&'a str, &'a str>>,
|
||||
settings: Option<HashMap<&'a str, &'a str>>,
|
||||
}
|
||||
|
||||
impl<'a> GraphQLPlaygroundConfig<'a> {
|
||||
|
@ -573,6 +574,7 @@ impl<'a> GraphQLPlaygroundConfig<'a> {
|
|||
endpoint,
|
||||
subscription_endpoint: None,
|
||||
headers: Default::default(),
|
||||
settings: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -593,4 +595,16 @@ impl<'a> GraphQLPlaygroundConfig<'a> {
|
|||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Set Playground setting for per query.
|
||||
pub fn with_setting(mut self, name: &'a str, value: &'a str) -> Self {
|
||||
if let Some(settings) = &mut self.settings {
|
||||
settings.insert(name, value);
|
||||
} else {
|
||||
let mut settings = HashMap::new();
|
||||
settings.insert(name, value);
|
||||
self.settings = Some(settings);
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user