diff --git a/juniper/Cargo.toml b/juniper/Cargo.toml index 5fdddfc36..025e5141b 100644 --- a/juniper/Cargo.toml +++ b/juniper/Cargo.toml @@ -46,6 +46,7 @@ graphql-parser = { version = "0.3", optional = true } indexmap = { version = "1.0", features = ["serde-1"] } serde = { version = "1.0.8", features = ["derive"], default-features = false } serde_json = { version = "1.0.2", default-features = false, optional = true } +smartstring = "0.2.6" static_assertions = "1.1" url = { version = "2.0", optional = true } uuid = { version = "0.8", default-features = false, optional = true } diff --git a/juniper/src/executor/mod.rs b/juniper/src/executor/mod.rs index 527e5540f..3bbb204c3 100644 --- a/juniper/src/executor/mod.rs +++ b/juniper/src/executor/mod.rs @@ -1158,7 +1158,7 @@ where T: GraphQLType + ?Sized, { Field { - name: name.to_owned(), + name: smartstring::SmartString::from(name), description: None, arguments: None, field_type: self.get_type::(info), @@ -1176,7 +1176,7 @@ where I: GraphQLType, { Field { - name: name.to_owned(), + name: smartstring::SmartString::from(name), description: None, arguments: None, field_type: self.get_type::(info), diff --git a/juniper/src/parser/lexer.rs b/juniper/src/parser/lexer.rs index d423d7946..c71c7ccf9 100644 --- a/juniper/src/parser/lexer.rs +++ b/juniper/src/parser/lexer.rs @@ -297,7 +297,7 @@ impl<'a> Lexer<'a> { } // Make sure we are on a valid char boundary. - let escape = &self + let escape = self .source .get(start_idx..=end_idx) .ok_or_else(|| Spanning::zero_width(&self.position, LexerError::UnterminatedString))?; diff --git a/juniper/src/schema/meta.rs b/juniper/src/schema/meta.rs index 518859f1a..7681539a0 100644 --- a/juniper/src/schema/meta.rs +++ b/juniper/src/schema/meta.rs @@ -158,7 +158,7 @@ pub enum MetaType<'a, S = DefaultScalarValue> { #[derive(Debug, Clone)] pub struct Field<'a, S> { #[doc(hidden)] - pub name: String, + pub name: smartstring::alias::String, #[doc(hidden)] pub description: Option, #[doc(hidden)] diff --git a/juniper/src/schema/schema.rs b/juniper/src/schema/schema.rs index 261da6422..f9a5a6f90 100644 --- a/juniper/src/schema/schema.rs +++ b/juniper/src/schema/schema.rs @@ -318,8 +318,8 @@ impl<'a, S> Field<'a, S> where S: crate::ScalarValue + 'a, { - fn name(&self) -> &String { - &self.name + fn name(&self) -> String { + self.name.clone().into() } fn description(&self) -> &Option {