Skip to content

Commit

Permalink
Add kind to normalization ast (#297)
Browse files Browse the repository at this point in the history
This converts NormalizationAst from NormalizationAstNode[] to object with kind: "NormalizationAst" so we can make it a union of NormalizationAstLoader and NormalizationAst in #271
  • Loading branch information
PatrykWalach authored Dec 28, 2024
1 parent 3a405a0 commit 1ee228e
Show file tree
Hide file tree
Showing 45 changed files with 2,930 additions and 2,813 deletions.
9 changes: 6 additions & 3 deletions crates/graphql_artifact_generation/src/entrypoint_artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub(crate) fn generate_entrypoint_artifacts_with_client_field_traversal_result<'
generate_refetch_query_artifact_import(&refetch_paths_with_variables, file_extensions);

let normalization_ast_text =
generate_normalization_ast_text(schema, merged_selection_map.values(), 0);
generate_normalization_ast_text(schema, merged_selection_map.values(), 1);

let concrete_type = schema.server_field_data.object(
if schema
Expand Down Expand Up @@ -294,7 +294,10 @@ impl EntrypointArtifactInfo<'_> {
import readerResolver from './{resolver_reader_file_name}{ts_file_extension}';\n\
{refetch_query_artifact_import}\n\n\
const queryText = '{query_text}';\n\n\
const normalizationAst: NormalizationAst = {normalization_ast_text};\n\
const normalizationAst: NormalizationAst = {{\n\
{}kind: \"NormalizationAst\",\n\
{}selections: {normalization_ast_text},\n\
}};\n\
const artifact: IsographEntrypoint<\n\
{}{entrypoint_params_typename},\n\
{}{entrypoint_output_type_name}\n\
Expand All @@ -313,7 +316,7 @@ impl EntrypointArtifactInfo<'_> {
{}}},\n\
}};\n\n\
export default artifact;\n",
" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ",
" "," "," ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ impl ImperativelyLoadedEntrypointArtifactInfo {
format!(
"import type {{ IsographEntrypoint, ReaderAst, FragmentReference, NormalizationAst, RefetchQueryNormalizationArtifact }} from '@isograph/react';\n\
const queryText = '{query_text}';\n\n\
const normalizationAst: NormalizationAst = {normalization_ast};\n\
const normalizationAst: NormalizationAst = {{\n\
{}kind: \"NormalizationAst\",\n\
{}selections: {normalization_ast},\n\
}};\n\
const artifact: RefetchQueryNormalizationArtifact = {{\n\
{}kind: \"RefetchQuery\",\n\
{}networkRequestInfo: {{\n\
Expand All @@ -72,6 +75,8 @@ impl ImperativelyLoadedEntrypointArtifactInfo {
" ",
" ",
" ",
" ",
" ",

)
}
Expand Down Expand Up @@ -103,7 +108,7 @@ pub(crate) fn get_artifact_for_imperatively_loaded_field(
);

let normalization_ast_text =
generate_normalization_ast_text(schema, merged_selection_set.values(), 0);
generate_normalization_ast_text(schema, merged_selection_set.values(), 1);

ImperativelyLoadedEntrypointArtifactInfo {
normalization_ast_text,
Expand Down
Loading

0 comments on commit 1ee228e

Please sign in to comment.