Skip to content

Commit

Permalink
Retain description for terse resolvers
Browse files Browse the repository at this point in the history
Reviewed By: tyao1

Differential Revision: D48176371

fbshipit-source-id: 3e8532d53bb179dd046ac0fe763b29c997d6258b
  • Loading branch information
captbaritone authored and facebook-github-bot committed Aug 9, 2023
1 parent 007eff0 commit a8dc8a9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
15 changes: 14 additions & 1 deletion compiler/crates/relay-docblock/src/docblock_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ use graphql_syntax::FragmentDefinition;
use graphql_syntax::Identifier;
use graphql_syntax::InputValueDefinition;
use graphql_syntax::List;
use graphql_syntax::StringNode;
use graphql_syntax::Token;
use graphql_syntax::TokenKind;
use graphql_syntax::TypeAnnotation;
use intern::Lookup;

Expand Down Expand Up @@ -102,6 +105,7 @@ pub(crate) fn parse_docblock_ir(
if populated_ir_field.value.item.lookup().contains('.') {
DocblockIr::TerseRelayResolver(parse_terse_relay_resolver_ir(
&mut fields,
description,
populated_ir_field,
definitions_in_file,
docblock_location,
Expand Down Expand Up @@ -262,6 +266,7 @@ fn parse_weak_object_ir(

fn parse_terse_relay_resolver_ir(
fields: &mut HashMap<AllowedFieldName, IrField>,
description: Option<WithLocation<StringKey>>,
relay_resolver_field: PopulatedIrField,
definitions_in_file: Option<&Vec<ExecutableDefinition>>,
location: Location,
Expand Down Expand Up @@ -295,12 +300,20 @@ fn parse_terse_relay_resolver_ir(
}
};

let field = parse_field_definition(
let mut field = parse_field_definition(
&remaining_source[1..],
type_str.location.source_location(),
span_start + 1,
)?;

field.description = description.map(|description| StringNode {
token: Token {
span: description.location.span(),
kind: TokenKind::Empty,
},
value: description.item,
});

if let TypeAnnotation::NonNull(non_null) = field.type_ {
return Err(vec![Diagnostic::error(
IrParsingErrorMessages::FieldWithNonNullType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ TerseRelayResolver(
),
arguments: None,
directives: [],
description: None,
description: Some(
StringNode {
token: Token {
span: 58:70,
kind: Empty,
},
value: "Non-nullable",
},
),
hack_source: None,
},
type_: WithLocation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ TerseRelayResolver(
),
arguments: None,
directives: [],
description: None,
description: Some(
StringNode {
token: Token {
span: 79:370,
kind: Empty,
},
value: "\nThe user's favorite page! They probably clicked something in the UI\nto tell us that it was their favorite page and then we put that in a\ndatabase or something. Then we got that info out again and put it out\nagain. Anyway, I'm rambling now. Its a page that the user likes. A lot.",
},
),
hack_source: None,
},
type_: WithLocation {
Expand Down

0 comments on commit a8dc8a9

Please sign in to comment.