Comments (3)
Maybe just do the same as for enum or input types, so instead of doing this
apollo-rs/crates/apollo-parser/src/parser/grammar/object.rs
Lines 40 to 42 in 208d2d7
just do sth. like
...
if let Some(T!['{']) = p.peek() {
object_fields_definition(p);
}
...
pub(crate) fn object_fields_definition(p: &mut Parser) {
let _g = p.start_node(SyntaxKind::FIELDS_DEFINITION);
p.bump(S!['{']);
if let Some(TokenKind::Name | TokenKind::StringValue) = p.peek() {
field::field_definition(p);
} else {
p.err("expected Field Definition");
}
while let Some(TokenKind::Name | TokenKind::StringValue) = p.peek() {
field::field_definition(p);
}
p.expect(T!['}'], S!['}']);
}
But at this point I'm wondering if there is any case where a list of definitions defined as e.g. here FieldsDefinitionlist is expected to possibly be empty. Because then it would need to be changed for the field grammar.
As you are more familiar with the GraphQL spec, you may know the answer, because I don't read it from the spec.
from apollo-rs.
I think you’re correct. In spec notation the "list" suffix is defined as "one or more": https://spec.graphql.org/October2021/#sec-Grammar-Notation.Optionality-and-Lists
There’s also "opt" for optional. Somethinglist opt is used for "zero or more":
from apollo-rs.
Ok then it needs to be changed in field grammar. If I'm right, this issue also exists for extensions and would be fixed in this way.
from apollo-rs.
Related Issues (20)
- [Parser] Empty type condition is not being caught in parse HOT 4
- Schema types to implement `Hash` HOT 4
- smith: use apollo-compiler types
- smith: generate a federation supergraph with @link
- Serialize schema without directive applications HOT 2
- fuzz:parser invalid input values
- fuzz:parser invalid float input values
- question: How to get type name of FieldDefinition's Return Type? HOT 3
- validate field merging when multiple sub-selections partially overlap
- `DirectiveList::into_iter` unexpectedly yields references HOT 2
- smith: add obfuscation functionality
- smith: generate a list of subgraphs
- [Apollo-Compiler][Feature Request] Expose validation data access HOT 2
- Merge error types in apollo-compiler
- parser::ty::named_type() can silently do nothing
- Harden `peek()` / `peek_data()` call pairs in the parser
- Avoid misuse in error handling in apollo-parser
- Enum values provided to scalars
- Pruning unused declarations after mutation HOT 1
- `apollo_compiler` encounters runtime error in wasm usages HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-rs.