-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Bundle Analysis v0.5 Update GraphQL schema #405
Changes from all commits
c5b1252
ea7b21e
10f7550
375095d
cfdd184
c0d7ef1
ba3dedf
7e5f281
401aa95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from graphql_api.helpers.ariadne import ariadne_load_local_graphql | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More boilerplate imports and refactored the folder structure to be:
before it was
|
||
|
||
from .base import ( | ||
bundle_asset_bindable, | ||
bundle_data_bindable, | ||
bundle_module_bindable, | ||
bundle_report_bindable, | ||
) | ||
from .comparison import ( | ||
bundle_analysis_comparison_bindable, | ||
bundle_analysis_comparison_result_bindable, | ||
bundle_comparison_bindable, | ||
) | ||
from .report import ( | ||
bundle_analysis_report_bindable, | ||
bundle_analysis_report_result_bindable, | ||
) | ||
|
||
bundle_analysis = ariadne_load_local_graphql(__file__, "base.graphql") | ||
bundle_analysis_comparison = ariadne_load_local_graphql(__file__, "comparison.graphql") | ||
bundle_analysis_report = ariadne_load_local_graphql(__file__, "report.graphql") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
type BundleSize { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the new types here, except |
||
gzip: Int! | ||
uncompress: Int! | ||
} | ||
|
||
type BundleLoadTime { | ||
threeG: Int! | ||
highSpeed: Int! | ||
} | ||
|
||
type BundleData { | ||
loadTime: BundleLoadTime! | ||
size: BundleSize! | ||
} | ||
|
||
type BundleModule { | ||
name: String! | ||
bundleData: BundleData! | ||
} | ||
|
||
type BundleAsset { | ||
name: String! | ||
normalizedName: String! | ||
moduleExtensions: [String!]! | ||
modules: [BundleModule]! | ||
bundleData: BundleData! | ||
} | ||
|
||
type BundleReport { | ||
name: String! | ||
sizeTotal: Int! | ||
loadTimeTotal: Float! | ||
moduleExtensions: [String!]! | ||
moduleCount: Int! | ||
assets(filters: BundleAnalysisReportFilters): [BundleAsset]! | ||
asset(name: String!): BundleAsset | ||
bundleData: BundleData! | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from typing import List, Mapping | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added lots of Unimplemented resolvers here for coming PRs and also implemented a new way to present size and load times. Also marked the old ways of calculating it to be removed when it is fully migrated on the FE. |
||
|
||
from ariadne import ObjectType | ||
|
||
from services.bundle_analysis import ( | ||
BundleData, | ||
BundleLoadTime, | ||
BundleReport, | ||
BundleSize, | ||
) | ||
|
||
bundle_data_bindable = ObjectType("BundleData") | ||
bundle_module_bindable = ObjectType("BundleModule") | ||
bundle_asset_bindable = ObjectType("BundleAsset") | ||
bundle_report_bindable = ObjectType("BundleReport") | ||
|
||
# ============= Bundle Data Bindable ============= | ||
|
||
|
||
@bundle_data_bindable.field("size") | ||
def resolve_bundle_size(bundle_data: BundleData, info) -> BundleSize: | ||
return bundle_data.size | ||
|
||
|
||
@bundle_data_bindable.field("loadTime") | ||
def resolve_bundle_load_time(bundle_data: BundleData, info) -> BundleLoadTime: | ||
return bundle_data.load_time | ||
|
||
|
||
# ============= Bundle Report Bindable ============= | ||
|
||
|
||
@bundle_report_bindable.field("name") | ||
def resolve_name(bundle_report: BundleReport, info) -> str: | ||
return bundle_report.bundle_name | ||
|
||
|
||
# TODO: depreacted with Issue 1199 | ||
@bundle_report_bindable.field("sizeTotal") | ||
def resolve_size_total(bundle_report: BundleReport, info) -> int: | ||
return bundle_report.size_total | ||
|
||
|
||
# TODO: depreacted with Issue 1199 | ||
@bundle_report_bindable.field("loadTimeTotal") | ||
def resolve_load_time_total(bundle_report: BundleReport, info) -> float: | ||
return bundle_report.load_time_total | ||
|
||
|
||
@bundle_report_bindable.field("moduleExtensions") | ||
def resolve_module_extensions(bundle_report: BundleReport, info) -> List[str]: | ||
# TODO: Unimplemented | ||
return [] | ||
|
||
|
||
@bundle_report_bindable.field("moduleCount") | ||
def resolve_module_count(bundle_report: BundleReport, info) -> List[str]: | ||
# TODO: Unimplemented | ||
return 0 | ||
|
||
|
||
@bundle_report_bindable.field("assets") | ||
def resolve_assets( | ||
bundle_report: BundleReport, | ||
info, | ||
filters: Mapping = None, | ||
) -> List[str]: | ||
# TODO: Unimplemented | ||
return [] | ||
|
||
|
||
@bundle_report_bindable.field("asset") | ||
def resolve_asset(bundle_report: BundleReport, info, name: str) -> List[str]: | ||
# TODO: Unimplemented | ||
return None | ||
|
||
|
||
@bundle_report_bindable.field("bundleData") | ||
def resolve_bundle_data(bundle_report: BundleReport, info) -> BundleData: | ||
return BundleData(bundle_report.size_total) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is all boilerplate imports