Skip to content

refactor: remove ScalarValue type parameter #782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions integration_tests/juniper_tests/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#[test]
fn operation_name_is_public() {
use juniper::{http::GraphQLRequest, DefaultScalarValue};
use juniper::http::GraphQLRequest;

let request = GraphQLRequest::<DefaultScalarValue>::new(
"query".to_string(),
Some("name".to_string()),
None,
);
let request = GraphQLRequest::new("query".to_string(), Some("name".to_string()), None);

assert_eq!(request.operation_name(), Some("name"));
}
11 changes: 4 additions & 7 deletions integration_tests/juniper_tests/src/codegen/derive_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ enum ContextEnum {
#[test]
fn test_derived_enum() {
// Ensure that rename works.
assert_eq!(
<SomeEnum as GraphQLType<DefaultScalarValue>>::name(&()),
Some("Some")
);
assert_eq!(<SomeEnum as GraphQLType>::name(&()), Some("Some"));

// Ensure validity of meta info.
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
Expand All @@ -70,7 +67,7 @@ fn test_derived_enum() {
InputValue::scalar("REGULAR")
);
assert_eq!(
FromInputValue::<DefaultScalarValue>::from_input_value(&InputValue::scalar("REGULAR")),
FromInputValue::from_input_value(&InputValue::scalar("REGULAR")),
Some(SomeEnum::Regular)
);

Expand All @@ -80,7 +77,7 @@ fn test_derived_enum() {
InputValue::scalar("FULL")
);
assert_eq!(
FromInputValue::<DefaultScalarValue>::from_input_value(&InputValue::scalar("FULL")),
FromInputValue::from_input_value(&InputValue::scalar("FULL")),
Some(SomeEnum::Full)
);
}
Expand Down Expand Up @@ -111,7 +108,7 @@ fn test_doc_comment_override() {

fn test_context<T>(_t: T)
where
T: GraphQLType<DefaultScalarValue, Context = CustomContext>,
T: GraphQLType<Context = CustomContext>,
{
// empty
}
Expand Down
16 changes: 5 additions & 11 deletions integration_tests/juniper_tests/src/codegen/derive_input_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct OverrideDocComment {
#[derive(Debug, PartialEq)]
struct Fake;

impl<'a> marker::IsInputType<DefaultScalarValue> for &'a Fake {}
impl<'a> marker::IsInputType for &'a Fake {}

impl<'a> FromInputValue for &'a Fake {
fn from_input_value(_v: &InputValue) -> Option<&'a Fake> {
Expand All @@ -64,14 +64,11 @@ impl<'a> ToInputValue for &'a Fake {
}
}

impl<'a> GraphQLType<DefaultScalarValue> for &'a Fake {
impl<'a> GraphQLType for &'a Fake {
fn name(_: &()) -> Option<&'static str> {
None
}
fn meta<'r>(_: &(), registry: &mut juniper::Registry<'r>) -> juniper::meta::MetaType<'r>
where
DefaultScalarValue: 'r,
{
fn meta<'r>(_: &(), registry: &mut juniper::Registry<'r>) -> juniper::meta::MetaType<'r> {
let meta = registry.build_enum_type::<&'a Fake>(
&(),
&[juniper::meta::EnumValue {
Expand All @@ -84,7 +81,7 @@ impl<'a> GraphQLType<DefaultScalarValue> for &'a Fake {
}
}

impl<'a> GraphQLValue<DefaultScalarValue> for &'a Fake {
impl<'a> GraphQLValue for &'a Fake {
type Context = ();
type TypeInfo = ();

Expand All @@ -101,10 +98,7 @@ struct WithLifetime<'a> {

#[test]
fn test_derived_input_object() {
assert_eq!(
<Input as GraphQLType<DefaultScalarValue>>::name(&()),
Some("MyInput")
);
assert_eq!(<Input as GraphQLType>::name(&()), Some("MyInput"));

// Validate meta info.
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
Expand Down
5 changes: 1 addition & 4 deletions integration_tests/juniper_tests/src/codegen/derive_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ async fn test_doc_comment_override() {

#[tokio::test]
async fn test_derived_object() {
assert_eq!(
<Obj as GraphQLType<DefaultScalarValue>>::name(&()),
Some("MyObj")
);
assert_eq!(<Obj as GraphQLType>::name(&()), Some("MyObj"));

// Verify meta info.
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
Expand Down
19 changes: 7 additions & 12 deletions integration_tests/juniper_tests/src/codegen/impl_scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ Syntax to validate:
*/

#[juniper::graphql_scalar]
impl<S> GraphQLScalar for DefaultName
where
S: juniper::ScalarValue,
{
impl GraphQLScalar for DefaultName {
fn resolve(&self) -> Value {
Value::scalar(self.0)
}
Expand All @@ -34,8 +31,8 @@ where
.map(|i| DefaultName(i))
}

fn from_str<'a>(value: juniper::ScalarToken<'a>) -> ParseScalarResult<'a, S> {
<i32 as ParseScalarValue<S>>::from_str(value)
fn from_str<'a>(value: juniper::ScalarToken<'a>) -> ParseScalarResult<'a> {
<i32 as ParseScalarValue>::from_str(value)
}
}

Expand All @@ -49,7 +46,7 @@ impl GraphQLScalar for OtherOrder {
v.as_scalar_value::<i32>().map(|i| OtherOrder(*i))
}

fn from_str<'a>(value: juniper::ScalarToken<'a>) -> ParseScalarResult<'a, DefaultScalarValue> {
fn from_str<'a>(value: juniper::ScalarToken<'a>) -> ParseScalarResult<'a> {
<i32 as ParseScalarValue>::from_str(value)
}
}
Expand All @@ -64,7 +61,7 @@ impl GraphQLScalar for Named {
v.as_scalar_value::<i32>().map(|i| Named(*i))
}

fn from_str<'a>(value: juniper::ScalarToken<'a>) -> ParseScalarResult<'a, DefaultScalarValue> {
fn from_str<'a>(value: juniper::ScalarToken<'a>) -> ParseScalarResult<'a> {
<i32 as ParseScalarValue>::from_str(value)
}
}
Expand All @@ -79,7 +76,7 @@ impl GraphQLScalar for ScalarDescription {
v.as_scalar_value::<i32>().map(|i| ScalarDescription(*i))
}

fn from_str<'a>(value: juniper::ScalarToken<'a>) -> ParseScalarResult<'a, DefaultScalarValue> {
fn from_str<'a>(value: juniper::ScalarToken<'a>) -> ParseScalarResult<'a> {
<i32 as ParseScalarValue>::from_str(value)
}
}
Expand Down Expand Up @@ -143,9 +140,7 @@ fn path_in_resolve_return_type() {
v.as_scalar_value::<i32>().map(|i| ResolvePath(*i))
}

fn from_str<'a>(
value: juniper::ScalarToken<'a>,
) -> ParseScalarResult<'a, DefaultScalarValue> {
fn from_str<'a>(value: juniper::ScalarToken<'a>) -> ParseScalarResult<'a> {
<i32 as ParseScalarValue>::from_str(value)
}
}
Expand Down
Loading