Skip to content

Commit

Permalink
Add location to Directive
Browse files Browse the repository at this point in the history
Reviewed By: captbaritone

Differential Revision: D64071264

fbshipit-source-id: fdee1729ac0ef630689a88176ab3a2c96ab6a622
  • Loading branch information
gordyf authored and facebook-github-bot committed Oct 23, 2024
1 parent 64806f2 commit b0c92e8
Show file tree
Hide file tree
Showing 37 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/crates/graphql-ir/src/associated_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ macro_rules! associated_data_impl {
name: $crate::reexport::WithLocation::generated($name::directive_name()),
arguments: Vec::new(),
data: Some(Box::new(item)),
location: $crate::reexport::WithLocation::generated($name::directive_name())
.location,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/crates/graphql-ir/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,7 @@ impl<'schema, 'signatures, 'options> Builder<'schema, 'signatures, 'options> {
.map(DirectiveName),
arguments: vec![],
data: None,
location: self.location.with_span(directive.span),
});
}
let directive_definition = match self
Expand Down Expand Up @@ -1420,6 +1421,7 @@ impl<'schema, 'signatures, 'options> Builder<'schema, 'signatures, 'options> {
),
arguments,
data: None,
location: self.location.with_span(directive.span),
})
}

Expand Down
1 change: 1 addition & 0 deletions compiler/crates/graphql-ir/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ pub struct Directive {
/// to attach arbitrary data on compiler-internal directives, such as to
/// pass instructions to code generation.
pub data: Option<Box<dyn AssociatedData>>,
pub location: Location,
}
impl Named for Directive {
type Name = DirectiveName;
Expand Down
2 changes: 2 additions & 0 deletions compiler/crates/graphql-ir/src/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ fn build_fragment_variable_definitions(
),
arguments: Vec::new(),
data: None,
location: fragment.location.with_span(unused_local_variable_arg.span)
});
}

Expand Down Expand Up @@ -334,6 +335,7 @@ fn build_fragment_variable_definitions(
original_variable_name: VariableName(variable_name.value),
fragment_source_location: fragment.location.source_location(),
})),
location: fragment.location.with_span(provider_arg.span),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fragment TestFragment on User
},
arguments: [],
data: None,
location: <generated>:89:102,
},
],
},
Expand Down Expand Up @@ -80,6 +81,7 @@ fragment TestFragment on User
},
arguments: [],
data: None,
location: argument_definitions.graphql:32:156,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ fragment TestFragment on User {
},
],
data: None,
location: directive-generic.graphql:37:64,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ query Test {
},
arguments: [],
data: None,
location: fixme_fat_interface_on_union.graphql:54:74,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ fragment Foo on User @argumentDefinitions(localId: {type: "ID!"}) {
},
arguments: [],
data: None,
location: fragment-with-arguments.graphql:32:126,
},
],
selections: [
Expand Down Expand Up @@ -276,6 +277,7 @@ fragment Foo on User @argumentDefinitions(localId: {type: "ID!"}) {
},
arguments: [],
data: None,
location: fragment-with-arguments.graphql:298:342,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ fragment ChildFragment on User
},
arguments: [],
data: None,
location: fragment-with-literal-arguments.graphql:119:169,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ fragment ChildFragment on User
},
arguments: [],
data: None,
location: fragment-with-literal-enum-arguments-into-enum-list.graphql:187:248,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ fragment ChildFragment on Query
},
arguments: [],
data: None,
location: fragment-with-literal-enum-arguments.graphql:188:245,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ fragment ChildFragment on User
},
arguments: [],
data: None,
location: fragment-with-literal-enum-list-arguments.graphql:189:250,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ fragment ChildFragment on Query
},
arguments: [],
data: None,
location: fragment-with-literal-object-arguments.graphql:205:263,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ fragment ChildFragment on Query
},
arguments: [],
data: None,
location: fragment-with-literal-object-list-arguments.graphql:208:270,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ fragment Foo($localId: ID!) on User {
},
arguments: [],
data: None,
location: fragment-with-variable-definitions-syntax.graphql:32:126,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fragment F2 on Query @argumentDefinitions(
},
arguments: [],
data: None,
location: fragment_with_arguments_defaulting.graphql:31:177,
},
],
selections: [
Expand Down Expand Up @@ -137,6 +138,7 @@ fragment F2 on Query @argumentDefinitions(
},
arguments: [],
data: None,
location: fragment_with_arguments_defaulting.graphql:248:298,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ fragment LinkedHandleField on User {
},
],
data: None,
location: linked-handle-field-with-filters.graphql:81:151,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fragment LinkedHandleField on User {
},
],
data: None,
location: linked-handle-field-with-key.graphql:62:135,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ fragment LinkedHandleField on User {
},
],
data: None,
location: linked-handle-field.graphql:62:101,
},
Directive {
name: WithLocation {
Expand Down Expand Up @@ -99,6 +100,7 @@ fragment LinkedHandleField on User {
},
],
data: None,
location: linked-handle-field.graphql:106:144,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ fragment LinkedHandleField on User {
},
],
data: None,
location: linked-handle-filter.graphql:62:121,
},
Directive {
name: WithLocation {
Expand Down Expand Up @@ -119,6 +120,7 @@ fragment LinkedHandleField on User {
},
],
data: None,
location: linked-handle-filter.graphql:126:164,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ fragment ScalarHandleField on User {
},
],
data: None,
location: scalar-handle-field.graphql:48:84,
},
Directive {
name: WithLocation {
Expand Down Expand Up @@ -80,6 +81,7 @@ fragment ScalarHandleField on User {
},
],
data: None,
location: scalar-handle-field.graphql:89:126,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ extend type Query {
},
],
data: None,
location: custom_scalar_directive_arg_variable.graphql:116:149,
},
],
selections: [
Expand Down Expand Up @@ -155,6 +156,7 @@ extend type Query {
},
],
data: None,
location: custom_scalar_directive_arg_variable.graphql:204:237,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ fragment TestFragment on User
},
},
),
location: fragment_with_valid_provider.graphql:173:199,
},
],
},
Expand Down Expand Up @@ -124,6 +125,7 @@ fragment TestFragment on User
},
arguments: [],
data: None,
location: fragment_with_valid_provider.graphql:32:205,
},
],
selections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ fragment ChildFragment2 on User
},
},
),
location: use_fragment_spread_with_provider.graphql:247:275,
},
],
},
Expand All @@ -154,6 +155,7 @@ fragment ChildFragment2 on User
},
arguments: [],
data: None,
location: use_fragment_spread_with_provider.graphql:141:280,
},
],
selections: [
Expand Down Expand Up @@ -270,6 +272,7 @@ fragment ChildFragment2 on User
},
},
),
location: use_fragment_spread_with_provider.graphql:487:515,
},
],
},
Expand All @@ -286,6 +289,7 @@ fragment ChildFragment2 on User
},
arguments: [],
data: None,
location: use_fragment_spread_with_provider.graphql:414:520,
},
],
selections: [
Expand Down
1 change: 1 addition & 0 deletions compiler/crates/relay-codegen/tests/request_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String>
),
}],
data: None,
location: operation.name.location,
}],
..operation.clone()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use std::sync::Arc;

use common::DirectiveName;
use common::Location;
use common::NamedItem;
use common::WithLocation;
use graphql_ir::Directive;
Expand Down Expand Up @@ -60,6 +61,7 @@ impl<'s> Transformer for AnnotateUpdatableFragmentSpreads<'s> {
name: WithLocation::generated(*UPDATABLE_DIRECTIVE_FOR_TYPEGEN),
arguments: vec![],
data: None,
location: Location::generated(),
});
Transformed::Replace(Selection::FragmentSpread(Arc::new(fragment_spread)))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use std::sync::Arc;

use common::DirectiveName;
use common::Location;
use common::NamedItem;
use common::WithLocation;
use graphql_ir::associated_data_impl;
Expand Down Expand Up @@ -122,6 +123,7 @@ fn get_directive(type_condition: Type, schema: &SDLSchema) -> Directive {
name: WithLocation::generated(*ASSIGNABLE_DIRECTIVE_FOR_TYPEGEN),
arguments: vec![],
data: Some(Box::new(get_associated_data(type_condition, schema))),
location: Location::generated(),
}
}

Expand Down
1 change: 1 addition & 0 deletions compiler/crates/relay-transforms/src/client_edges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ fn make_refetchable_directive(query_name: OperationDefinitionName) -> Directive
value: WithLocation::generated(Value::Constant(ConstantValue::String(query_name.0))),
}],
data: None,
location: Location::generated(),
}
}

Expand Down
1 change: 1 addition & 0 deletions compiler/crates/relay-transforms/src/client_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,6 @@ fn build_client_extension_directive() -> Directive {
name: WithLocation::generated(*CLIENT_EXTENSION_DIRECTIVE_NAME),
arguments: Default::default(),
data: None,
location: Location::generated(),
}
}
2 changes: 2 additions & 0 deletions compiler/crates/relay-transforms/src/defer_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ impl DeferStreamTransform<'_> {
name: defer.name,
arguments: next_arguments,
data: None,
location: defer.location,
};

Ok(Transformed::Replace(Selection::InlineFragment(Arc::new(
Expand Down Expand Up @@ -264,6 +265,7 @@ impl DeferStreamTransform<'_> {
name: stream.name,
arguments: next_arguments,
data: None,
location: stream.location,
};

Ok(get_next_selection(replace_directive(
Expand Down
1 change: 1 addition & 0 deletions compiler/crates/relay-transforms/src/generate_typename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ fn generate_abstract_key_field(
name: WithLocation::new(location, *TYPE_DISCRIMINATOR_DIRECTIVE_NAME),
arguments: vec![],
data: None,
location,
}]
} else {
vec![]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use common::ArgumentName;
use common::DirectiveName;
use common::Location;
use common::WithLocation;
use graphql_ir::Argument;
use graphql_ir::ConstantValue;
Expand Down Expand Up @@ -140,6 +141,7 @@ pub fn build_handle_field_directive(values: HandleFieldDirectiveValues) -> Direc
name: WithLocation::generated(*HANDLE_FIELD_DIRECTIVE_NAME),
arguments: directive_arguments,
data: None,
location: Location::generated(),
}
}

Expand Down
Loading

0 comments on commit b0c92e8

Please sign in to comment.