Skip to content

Commit 7725a27

Browse files
authored
Rename ast::VariableDefinitions to ast::VariablesDefinition (#1353, #1347, graphql/graphql-spec#916)
- rename `ast::Operation::variable_definitions` field to `variables_definition`
1 parent 180a513 commit 7725a27

File tree

7 files changed

+32
-28
lines changed

7 files changed

+32
-28
lines changed

juniper/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
1616
- Made `includeDeprecated` argument of `__Type.fields`, `__Type.enumValues`, `__Type.inputFields`, `__Field.args` and `__Directive.args` fields non-`Null`. ([#1348], [graphql/graphql-spec#1142])
1717
- Made `@deprecated(reason:)` argument non-`Null`. ([#1348], [graphql/graphql-spec#1040])
1818
- Added `description` field to `ast::Operation`, `ast::Fragment` and `ast::VariableDefinition`. ([#1349], [graphql/graphql-spec#1170])
19+
- Renamed `ast::VariableDefinitions` to `ast::VariablesDefinition`: ([#1353], [graphql/graphql-spec#916])
20+
- Renamed `ast::Operation::variable_definitions` field to `variables_definition`.
1921
- Changed `ScalarToken::String` to contain raw quoted and escaped `StringLiteral` (was unquoted but escaped string before). ([#1349])
2022
- Added `LexerError::UnterminatedBlockString` variant. ([#1349])
2123

@@ -51,11 +53,13 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
5153
[#1347]: /../../issues/1347
5254
[#1348]: /../../pull/1348
5355
[#1349]: /../../pull/1349
56+
[#1353]: /../../pull/1353
5457
[graphql/graphql-spec#525]: https://github.com/graphql/graphql-spec/pull/525
5558
[graphql/graphql-spec#687]: https://github.com/graphql/graphql-spec/issues/687
5659
[graphql/graphql-spec#805]: https://github.com/graphql/graphql-spec/pull/805
5760
[graphql/graphql-spec#825]: https://github.com/graphql/graphql-spec/pull/825
5861
[graphql/graphql-spec#849]: https://github.com/graphql/graphql-spec/pull/849
62+
[graphql/graphql-spec#916]: https://github.com/graphql/graphql-spec/pull/916
5963
[graphql/graphql-spec#1040]: https://github.com/graphql/graphql-spec/pull/1040
6064
[graphql/graphql-spec#1142]: https://github.com/graphql/graphql-spec/pull/1142
6165
[graphql/graphql-spec#1170]: https://github.com/graphql/graphql-spec/pull/1170

juniper/src/ast.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,16 @@ pub struct Arguments<'a, S> {
319319
}
320320

321321
#[derive(Clone, Debug, PartialEq)]
322-
pub struct VariableDefinitions<'a, S> {
322+
pub struct VariablesDefinition<'a, S> {
323323
pub items: Vec<(Spanning<&'a str>, VariableDefinition<'a, S>)>,
324324
}
325325

326+
impl<'a, S> VariablesDefinition<'a, S> {
327+
pub fn iter(&self) -> slice::Iter<'_, (Spanning<&'a str>, VariableDefinition<'a, S>)> {
328+
self.items.iter()
329+
}
330+
}
331+
326332
#[derive(Clone, Debug, PartialEq)]
327333
pub struct Field<'a, S> {
328334
pub alias: Option<Spanning<&'a str>>,
@@ -388,7 +394,7 @@ pub struct Operation<'a, S> {
388394
pub description: Option<Spanning<Cow<'a, str>>>,
389395
pub operation_type: OperationType,
390396
pub name: Option<Spanning<&'a str>>,
391-
pub variable_definitions: Option<Spanning<VariableDefinitions<'a, S>>>,
397+
pub variables_definition: Option<Spanning<VariablesDefinition<'a, S>>>,
392398
pub directives: Option<Vec<Spanning<Directive<'a, S>>>>,
393399
pub selection_set: Vec<Selection<'a, S>>,
394400
}
@@ -824,12 +830,6 @@ impl<'a, S> Arguments<'a, S> {
824830
}
825831
}
826832

827-
impl<'a, S> VariableDefinitions<'a, S> {
828-
pub fn iter(&self) -> slice::Iter<'_, (Spanning<&'a str>, VariableDefinition<'a, S>)> {
829-
self.items.iter()
830-
}
831-
}
832-
833833
#[cfg(test)]
834834
mod spec_input_value_fmt {
835835
use crate::graphql;

juniper/src/executor/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ where
820820
};
821821
}
822822

823-
let default_variable_values = operation.item.variable_definitions.as_ref().map(|defs| {
823+
let default_variable_values = operation.item.variables_definition.as_ref().map(|defs| {
824824
defs.item
825825
.items
826826
.iter()
@@ -918,7 +918,7 @@ where
918918
};
919919
}
920920

921-
let default_variable_values = operation.item.variable_definitions.as_ref().map(|defs| {
921+
let default_variable_values = operation.item.variables_definition.as_ref().map(|defs| {
922922
defs.item
923923
.items
924924
.iter()
@@ -1065,7 +1065,7 @@ where
10651065
}
10661066
}
10671067

1068-
let default_variable_values = operation.item.variable_definitions.as_ref().map(|defs| {
1068+
let default_variable_values = operation.item.variables_definition.as_ref().map(|defs| {
10691069
defs.item
10701070
.items
10711071
.iter()

juniper/src/parser/document.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
ast::{
55
Arguments, Definition, Directive, Field, Fragment, FragmentSpread, InlineFragment,
66
InputValue, Operation, OperationType, OwnedDocument, Selection, Type, VariableDefinition,
7-
VariableDefinitions,
7+
VariablesDefinition,
88
},
99
parser::{
1010
Lexer, OptionParseResult, ParseError, ParseResult, Parser, ScalarToken, Spanning, Token,
@@ -94,7 +94,7 @@ where
9494
operation_type: OperationType::Query,
9595
name: None,
9696
description: None,
97-
variable_definitions: None,
97+
variables_definition: None,
9898
directives: None,
9999
selection_set: selection_set.item,
100100
},
@@ -114,7 +114,7 @@ where
114114
Token::Name(_) => Some(parser.expect_name()?),
115115
_ => None,
116116
};
117-
let variable_definitions = parse_variable_definitions(parser, schema)?;
117+
let variables_definition = parse_variables_definition(parser, schema)?;
118118
let directives = parse_directives(parser, schema)?;
119119
let selection_set = parse_selection_set(parser, schema, fields)?;
120120

@@ -125,7 +125,7 @@ where
125125
operation_type: operation_type.item,
126126
name,
127127
description: None,
128-
variable_definitions,
128+
variables_definition,
129129
directives: directives.map(|s| s.item),
130130
selection_set: selection_set.item,
131131
},
@@ -409,10 +409,10 @@ fn parse_operation_type(parser: &mut Parser<'_>) -> ParseResult<OperationType> {
409409
}
410410
}
411411

412-
fn parse_variable_definitions<'a, S>(
412+
fn parse_variables_definition<'a, S>(
413413
parser: &mut Parser<'a>,
414414
schema: &SchemaType<S>,
415-
) -> OptionParseResult<VariableDefinitions<'a, S>>
415+
) -> OptionParseResult<VariablesDefinition<'a, S>>
416416
where
417417
S: ScalarValue,
418418
{
@@ -426,7 +426,7 @@ where
426426
|p| parse_variable_definition(p, schema),
427427
&Token::ParenClose,
428428
)?
429-
.map(|defs| VariableDefinitions {
429+
.map(|defs| VariablesDefinition {
430430
items: defs.into_iter().map(|s| s.item).collect(),
431431
}),
432432
))

juniper/src/parser/tests/document.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn simple_ast() {
4949
operation_type: ast::OperationType::Query,
5050
name: None,
5151
description: None,
52-
variable_definitions: None,
52+
variables_definition: None,
5353
directives: None,
5454
selection_set: vec![ast::Selection::Field(Spanning::start_end(
5555
&SourcePosition::new(18, 1, 16),
@@ -168,10 +168,10 @@ fn description() {
168168
&SourcePosition::new(54, 1, 53),
169169
Cow::Owned("Some description with \u{90AB} symbol".into()),
170170
)),
171-
variable_definitions: Some(Spanning::start_end(
171+
variables_definition: Some(Spanning::start_end(
172172
&SourcePosition::new(90, 2, 35),
173173
&SourcePosition::new(364, 10, 17),
174-
ast::VariableDefinitions {
174+
ast::VariablesDefinition {
175175
items: vec![
176176
(
177177
Spanning::start_end(

juniper/src/validation/input_value.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::collections::HashSet;
33
use derive_more::with_trait::Display;
44

55
use crate::{
6-
ast::{InputValue, Operation, VariableDefinitions},
6+
ast::{InputValue, Operation, VariablesDefinition},
77
executor::Variables,
88
parser::{SourcePosition, Spanning},
99
schema::{
@@ -35,7 +35,7 @@ where
3535
{
3636
let mut errs = vec![];
3737

38-
if let Some(ref vars) = operation.item.variable_definitions {
38+
if let Some(ref vars) = operation.item.variables_definition {
3939
validate_var_defs(values, &vars.item, schema, &mut errs);
4040
}
4141

@@ -45,7 +45,7 @@ where
4545

4646
fn validate_var_defs<S>(
4747
values: &Variables<S>,
48-
var_defs: &VariableDefinitions<S>,
48+
var_defs: &VariablesDefinition<S>,
4949
schema: &SchemaType<S>,
5050
errors: &mut Vec<RuleError>,
5151
) where

juniper/src/validation/visitor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
ast::{
33
Arguments, BorrowedType, Definition, Directive, Document, Field, Fragment, FragmentSpread,
4-
InlineFragment, InputValue, Operation, OperationType, Selection, VariableDefinitions,
4+
InlineFragment, InputValue, Operation, OperationType, Selection, VariablesDefinition,
55
},
66
parser::Spanning,
77
schema::meta::Argument,
@@ -109,7 +109,7 @@ where
109109
{
110110
match *def {
111111
Definition::Operation(ref op) => {
112-
visit_variable_definitions(v, ctx, &op.item.variable_definitions);
112+
visit_variables_definition(v, ctx, &op.item.variables_definition);
113113
visit_directives(v, ctx, &op.item.directives);
114114
visit_selection_set(v, ctx, &op.item.selection_set);
115115
}
@@ -120,10 +120,10 @@ where
120120
}
121121
}
122122

123-
fn visit_variable_definitions<'a, S, V>(
123+
fn visit_variables_definition<'a, S, V>(
124124
v: &mut V,
125125
ctx: &mut ValidatorContext<'a, S>,
126-
defs: &'a Option<Spanning<VariableDefinitions<S>>>,
126+
defs: &'a Option<Spanning<VariablesDefinition<S>>>,
127127
) where
128128
S: ScalarValue,
129129
V: Visitor<'a, S>,

0 commit comments

Comments
 (0)