Skip to content

Commit 27ded82

Browse files
committed
Use fully qualified paths in generated code
Isolates the generated code from any new types or aliases introduced in user code.
1 parent 24c3ee7 commit 27ded82

File tree

13 files changed

+111
-111
lines changed

13 files changed

+111
-111
lines changed

juniper_codegen/src/common/deprecation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ impl ToTokens for Directive {
105105
let reason = self
106106
.reason
107107
.as_ref()
108-
.map_or_else(|| quote! { None }, |text| quote! { Some(#text) });
108+
.map_or_else(|| quote! { ::std::option::Option::None }, |text| quote! { ::std::option::Option::Some(#text) });
109109
quote! {
110-
.deprecated(::std::option::Option::#reason)
110+
.deprecated(#reason)
111111
}
112112
.to_tokens(into);
113113
}

juniper_codegen/src/common/field/arg.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,13 @@ impl OnMethod {
335335
::juniper::IntoFieldError::<#scalar>::into_field_error(e)
336336
.map_message(|m| format!(#err_text, m))
337337
})
338-
}, Ok))
338+
}, ::std::result::Result::Ok))
339339
};
340340
if for_async {
341341
quote! {
342342
match #arg {
343-
Ok(v) => v,
344-
Err(e) => return Box::pin(async { Err(e) }),
343+
::std::result::Result::Ok(v) => v,
344+
::std::result::Result::Err(e) => return ::std::boxed::Box::pin(async { ::std::result::Result::Err(e) }),
345345
}
346346
}
347347
} else {

juniper_codegen/src/common/field/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl Definition {
227227
ty_name: &str,
228228
) -> TokenStream {
229229
quote! {
230-
return Err(::juniper::FieldError::from(::std::format!(
230+
return ::std::result::Result::Err(::juniper::FieldError::from(::std::format!(
231231
"Field `{}` not found on type `{}`",
232232
field,
233233
<Self as ::juniper::GraphQLType<#scalar>>::name(info)
@@ -354,18 +354,18 @@ impl Definition {
354354
async move {
355355
let ex = executor.as_executor();
356356
match res2 {
357-
Ok(Some((ctx, r))) => {
357+
::std::result::Result::Ok(::std::option::Option::Some((ctx, r))) => {
358358
let sub = ex.replaced_context(ctx);
359359
sub.resolve_with_ctx_async(&(), &r)
360360
.await
361361
.map_err(|e| ex.new_error(e))
362362
}
363-
Ok(None) => Ok(::juniper::Value::null()),
364-
Err(e) => Err(ex.new_error(e)),
363+
::std::result::Result::Ok(::std::option::Option::None) => ::std::result::Result::Ok(::juniper::Value::null()),
364+
::std::result::Result::Err(e) => ::std::result::Result::Err(ex.new_error(e)),
365365
}
366366
}
367367
});
368-
Ok(::juniper::Value::Scalar::<
368+
::std::result::Result::Ok(::juniper::Value::Scalar::<
369369
::juniper::ValuesStream::<#scalar>
370370
>(::juniper::futures::StreamExt::boxed(stream)))
371371
})

juniper_codegen/src/common/gen.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pub(crate) fn sync_resolving_code() -> TokenStream {
1313
quote! {
1414
::juniper::IntoResolvable::into_resolvable(res, executor.context())
1515
.and_then(|res| match res {
16-
Some((ctx, r)) => executor.replaced_context(ctx).resolve_with_ctx(info, &r),
17-
None => Ok(::juniper::Value::null()),
16+
::std::option::Option::Some((ctx, r)) => executor.replaced_context(ctx).resolve_with_ctx(info, &r),
17+
::std::option::Option::None => ::std::result::Result::Ok(::juniper::Value::null()),
1818
})
1919
}
2020
}
@@ -34,13 +34,13 @@ pub(crate) fn async_resolving_code(ty: Option<&syn::Type>) -> TokenStream {
3434
let ty = ty.map(|t| quote! { : #t });
3535

3636
quote! {
37-
Box::pin(::juniper::futures::FutureExt::then(fut, move |res #ty| async move {
37+
::std::boxed::Box::pin(::juniper::futures::FutureExt::then(fut, move |res #ty| async move {
3838
match ::juniper::IntoResolvable::into_resolvable(res, executor.context())? {
39-
Some((ctx, r)) => {
39+
::std::option::Option::Some((ctx, r)) => {
4040
let subexec = executor.replaced_context(ctx);
4141
subexec.resolve_with_ctx_async(info, &r).await
4242
},
43-
None => Ok(::juniper::Value::null()),
43+
::std::option::Option::None => ::std::result::Result::Ok(::juniper::Value::null()),
4444
}
4545
}))
4646
}

juniper_codegen/src/graphql_enum/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ impl Definition {
450450
for #ident #ty_generics
451451
#where_clause
452452
{
453-
fn name(_ : &Self::TypeInfo) -> Option<&'static str> {
454-
Some(#name)
453+
fn name(_ : &Self::TypeInfo) -> ::std::option::Option<&'static ::std::primitive::str> {
454+
::std::option::Option::Some(#name)
455455
}
456456

457457
fn meta<'r>(
@@ -489,13 +489,13 @@ impl Definition {
489489
let name = &v.name;
490490

491491
quote! {
492-
Self::#ident => Ok(::juniper::Value::scalar(String::from(#name))),
492+
Self::#ident => ::std::result::Result::Ok(::juniper::Value::scalar(::std::string::String::from(#name))),
493493
}
494494
});
495495

496496
let ignored = self.has_ignored_variants.then(|| {
497497
quote! {
498-
_ => Err(::juniper::FieldError::<#scalar>::from(
498+
_ => ::std::result::Result::Err(::juniper::FieldError::<#scalar>::from(
499499
"Cannot resolve ignored enum variant",
500500
)),
501501
}
@@ -509,14 +509,14 @@ impl Definition {
509509
type Context = #context;
510510
type TypeInfo = ();
511511

512-
fn type_name<'__i>(&self, info: &'__i Self::TypeInfo) -> Option<&'__i str> {
512+
fn type_name<'__i>(&self, info: &'__i Self::TypeInfo) -> ::std::option::Option<&'__i ::std::primitive::str> {
513513
<Self as ::juniper::GraphQLType<#scalar>>::name(info)
514514
}
515515

516516
fn resolve(
517517
&self,
518518
_: &(),
519-
_: Option<&[::juniper::Selection<#scalar>]>,
519+
_: ::std::option::Option<&[::juniper::Selection<#scalar>]>,
520520
_: &::juniper::Executor<Self::Context, #scalar>,
521521
) -> ::juniper::ExecutionResult<#scalar> {
522522
match self {
@@ -549,11 +549,11 @@ impl Definition {
549549
fn resolve_async<'__a>(
550550
&'__a self,
551551
info: &'__a Self::TypeInfo,
552-
selection_set: Option<&'__a [::juniper::Selection<#scalar>]>,
552+
selection_set: ::std::option::Option<&'__a [::juniper::Selection<#scalar>]>,
553553
executor: &'__a ::juniper::Executor<Self::Context, #scalar>,
554554
) -> ::juniper::BoxFuture<'__a, ::juniper::ExecutionResult<#scalar>> {
555555
let v = ::juniper::GraphQLValue::resolve(self, info, selection_set, executor);
556-
Box::pin(::juniper::futures::future::ready(v))
556+
::std::boxed::Box::pin(::juniper::futures::future::ready(v))
557557
}
558558
}
559559
}
@@ -577,7 +577,7 @@ impl Definition {
577577
let name = &v.name;
578578

579579
quote! {
580-
Some(#name) => Ok(Self::#ident),
580+
::std::option::Option::Some(#name) => ::std::result::Result::Ok(Self::#ident),
581581
}
582582
});
583583

@@ -591,7 +591,7 @@ impl Definition {
591591
fn from_input_value(v: &::juniper::InputValue<#scalar>) -> ::std::result::Result<Self, Self::Error> {
592592
match v.as_enum_value().or_else(|| v.as_string_value()) {
593593
#( #variants )*
594-
_ => Err(::std::format!("Unknown enum value: {}", v)),
594+
_ => ::std::result::Result::Err(::std::format!("Unknown enum value: {}", v)),
595595
}
596596
}
597597
}
@@ -617,14 +617,14 @@ impl Definition {
617617

618618
quote! {
619619
#ident::#var_ident => ::juniper::InputValue::<#scalar>::scalar(
620-
String::from(#name),
620+
::std::string::String::from(#name),
621621
),
622622
}
623623
});
624624

625625
let ignored = self.has_ignored_variants.then(|| {
626626
quote! {
627-
_ => panic!("Cannot resolve ignored enum variant"),
627+
_ => ::std::panic!("Cannot resolve ignored enum variant"),
628628
}
629629
});
630630

@@ -730,13 +730,13 @@ impl Definition {
730730
generics
731731
.make_where_clause()
732732
.predicates
733-
.push(parse_quote! { #self_ty: Sync });
733+
.push(parse_quote! { #self_ty: ::std::marker::Sync });
734734

735735
if scalar.is_generic() {
736736
generics
737737
.make_where_clause()
738738
.predicates
739-
.push(parse_quote! { #scalar: Send + Sync });
739+
.push(parse_quote! { #scalar: ::std::marker::Send + ::std::marker::Sync });
740740
}
741741
}
742742

juniper_codegen/src/graphql_input_object/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@ impl Definition {
479479
for #ident #ty_generics
480480
#where_clause
481481
{
482-
fn name(_: &Self::TypeInfo) -> Option<&'static str> {
483-
Some(#name)
482+
fn name(_: &Self::TypeInfo) -> ::std::option::Option<&'static ::std::primitive::str> {
483+
::std::option::Option::Some(#name)
484484
}
485485

486486
fn meta<'r>(
@@ -524,7 +524,7 @@ impl Definition {
524524
type Context = #context;
525525
type TypeInfo = ();
526526

527-
fn type_name<'__i>(&self, info: &'__i Self::TypeInfo) -> Option<&'__i str> {
527+
fn type_name<'__i>(&self, info: &'__i Self::TypeInfo) -> ::std::option::Option<&'__i ::std::primitive::str> {
528528
<Self as ::juniper::GraphQLType<#scalar>>::name(info)
529529
}
530530
}
@@ -594,11 +594,11 @@ impl Definition {
594594

595595
quote! {
596596
match obj.get(#name) {
597-
Some(v) => {
597+
::std::option::Option::Some(v) => {
598598
::juniper::FromInputValue::<#scalar>::from_input_value(v)
599599
.map_err(::juniper::IntoFieldError::into_field_error)?
600600
}
601-
None => { #fallback }
601+
::std::option::Option::None => { #fallback }
602602
}
603603
}
604604
};
@@ -623,7 +623,7 @@ impl Definition {
623623
::std::format!("Expected input object, found: {}", value))
624624
)?;
625625

626-
Ok(#ident {
626+
::std::result::Result::Ok(#ident {
627627
#( #fields )*
628628
})
629629
}
@@ -763,13 +763,13 @@ impl Definition {
763763
generics
764764
.make_where_clause()
765765
.predicates
766-
.push(parse_quote! { #self_ty: Sync });
766+
.push(parse_quote! { #self_ty: ::core::marker::Sync });
767767

768768
if scalar.is_generic() {
769769
generics
770770
.make_where_clause()
771771
.predicates
772-
.push(parse_quote! { #scalar: Send + Sync });
772+
.push(parse_quote! { #scalar: ::core::marker::Send + ::core::marker::Sync });
773773
}
774774
}
775775

juniper_codegen/src/graphql_interface/mod.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ impl Definition {
487487

488488
quote! {
489489
#[automatically_derived]
490-
#[derive(Clone, Copy, Debug)]
490+
#[derive(::std::clone::Clone, ::std::marker::Copy, ::std::fmt::Debug)]
491491
#[doc = #enum_doc]
492492
#vis enum #enum_ident #enum_gens {
493493
#( #[doc(hidden)] #variants_idents(#variant_gens_pars), )*
@@ -523,12 +523,12 @@ impl Definition {
523523

524524
quote! {{
525525
const SUPPRESS_DEAD_CODE: () = {
526-
let none = Option::<#ident #const_gens>::None;
526+
let none = ::std::option::Option::<#ident #const_gens>::None;
527527
match none {
528-
Some(unreachable) => {
528+
::std::option::Option::Some(unreachable) => {
529529
#( let _ = unreachable.#fields; )*
530530
}
531-
None => {}
531+
::std::option::Option::None => {}
532532
}
533533
};
534534
let _ = SUPPRESS_DEAD_CODE;
@@ -715,8 +715,8 @@ impl Definition {
715715
for #ty #ty_generics
716716
#where_clause
717717
{
718-
fn name(_ : &Self::TypeInfo) -> Option<&'static str> {
719-
Some(#name)
718+
fn name(_ : &Self::TypeInfo) -> ::std::option::Option<&'static ::std::primitive::str> {
719+
std::option::Option::Some(#name)
720720
}
721721

722722
fn meta<'r>(
@@ -784,14 +784,14 @@ impl Definition {
784784
type Context = #context;
785785
type TypeInfo = ();
786786

787-
fn type_name<'__i>(&self, info: &'__i Self::TypeInfo) -> Option<&'__i str> {
787+
fn type_name<'__i>(&self, info: &'__i Self::TypeInfo) -> std::option::Option<&'__i ::std::primitive::str> {
788788
<Self as ::juniper::GraphQLType<#scalar>>::name(info)
789789
}
790790

791791
fn resolve_field(
792792
&self,
793793
info: &Self::TypeInfo,
794-
field: &str,
794+
field: &::std::primitive::str,
795795
args: &::juniper::Arguments<'_, #scalar>,
796796
executor: &::juniper::Executor<'_, '_, Self::Context, #scalar>,
797797
) -> ::juniper::ExecutionResult<#scalar> {
@@ -805,15 +805,15 @@ impl Definition {
805805
&self,
806806
context: &Self::Context,
807807
info: &Self::TypeInfo,
808-
) -> String {
808+
) -> ::std::string::String {
809809
#downcast_check
810810
}
811811

812812
fn resolve_into_type(
813813
&self,
814814
info: &Self::TypeInfo,
815-
type_name: &str,
816-
_: Option<&[::juniper::Selection<'_, #scalar>]>,
815+
type_name: &::std::primitive::str,
816+
_: ::std::option::Option<&[::juniper::Selection<'_, #scalar>]>,
817817
executor: &::juniper::Executor<'_, '_, Self::Context, #scalar>,
818818
) -> ::juniper::ExecutionResult<#scalar> {
819819
#downcast
@@ -862,21 +862,21 @@ impl Definition {
862862
fn resolve_field_async<'b>(
863863
&'b self,
864864
info: &'b Self::TypeInfo,
865-
field: &'b str,
865+
field: &'b ::std::primitive::str,
866866
args: &'b ::juniper::Arguments<'_, #scalar>,
867867
executor: &'b ::juniper::Executor<'_, '_, Self::Context, #scalar>,
868868
) -> ::juniper::BoxFuture<'b, ::juniper::ExecutionResult<#scalar>> {
869869
match field {
870870
#( #fields_resolvers )*
871-
_ => Box::pin(async move { #no_field_err }),
871+
_ => ::std::boxed::Box::pin(async move { #no_field_err }),
872872
}
873873
}
874874

875875
fn resolve_into_type_async<'b>(
876876
&'b self,
877877
info: &'b Self::TypeInfo,
878-
type_name: &str,
879-
_: Option<&'b [::juniper::Selection<'b, #scalar>]>,
878+
type_name: &::std::primitive::str,
879+
_: ::std::option::Option<&'b [::juniper::Selection<'b, #scalar>]>,
880880
executor: &'b ::juniper::Executor<'b, 'b, Self::Context, #scalar>
881881
) -> ::juniper::BoxFuture<'b, ::juniper::ExecutionResult<#scalar>> {
882882
#downcast
@@ -1360,13 +1360,13 @@ impl Definition {
13601360
generics
13611361
.make_where_clause()
13621362
.predicates
1363-
.push(parse_quote! { #self_ty: Sync });
1363+
.push(parse_quote! { #self_ty: ::std::marker::Sync });
13641364

13651365
if scalar.is_generic() {
13661366
generics
13671367
.make_where_clause()
13681368
.predicates
1369-
.push(parse_quote! { #scalar: Send + Sync });
1369+
.push(parse_quote! { #scalar: ::std::marker::Send + ::std::marker::Sync });
13701370
}
13711371
}
13721372

0 commit comments

Comments
 (0)