+
Skip to content

Conversation

l0ngvh
Copy link
Contributor

@l0ngvh l0ngvh commented Apr 22, 2024

Summary

Parse GraphQL schema definition. This is a small case so I parse both the happy path and error path in this PR

Test Plan

All tests should pass

@l0ngvh l0ngvh marked this pull request as ready for review April 22, 2024 10:33
Copy link

codspeed-hq bot commented Apr 22, 2024

CodSpeed Performance Report

Merging #2557 will not alter performance

Comparing vohoanglong0107:feat-graphql-parse-schema-definition (42c0b7f) with main (1abda0c)

Summary

✅ 88 untouched benchmarks

}

fn is_at_list_end(&self, p: &mut Self::Parser<'_>) -> bool {
is_at_root_operation_type_definition_end(p)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please help me to understand why we need here is_at_root_operation_type_definition_end?
What cases do we cover? Is it possible to check only p.at(T!['}'])?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider this case:

schema {
  query: MyQueryRootType
  mutation: MyMutationRootType

schema {
  query: Query
}

If we only check for p.at(T!['}']) the second schema definition is also included in RootOperationType, so I included another check to see if we are at the start of other definition or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this is a good idea?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's a great idea.

I'm wondering if it's possible to have a 'complex' check when we get an Absent result from the parse_element function.
Specifically, it would be beneficial to maintain p.at(T!['}']) the happy path, avoiding additional checks which are required for the failure path.

I don't have any work solution for now, we might think about it in the next MR.

@l0ngvh l0ngvh requested a review from denbezrukov April 23, 2024 06:45

#[inline]
fn parse_root_operation_type_definition(p: &mut GraphqlParser) -> ParsedSyntax {
if !(p.at_ts(OPERATION_TYPE) || p.at(T![:]) || p.lookahead_at(T![:])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can extract p.at_ts(OPERATION_TYPE) || p.at(T![:]) || p.lookahead_at(T![:]) as a is_at_root_operation_type_definition function and reuse it in the RootOperationTypeDefinitionListRecovery.

Copy link
Contributor

@denbezrukov denbezrukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀🚀🚀

@l0ngvh l0ngvh force-pushed the feat-graphql-parse-schema-definition branch from 3db791d to 00dc3b2 Compare April 23, 2024 11:41
@l0ngvh l0ngvh force-pushed the feat-graphql-parse-schema-definition branch from 00dc3b2 to 42c0b7f Compare April 29, 2024 03:44
Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!

@arendjr arendjr merged commit 5fda633 into biomejs:main May 1, 2024
@l0ngvh l0ngvh deleted the feat-graphql-parse-schema-definition branch May 1, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载