Skip to content
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

fix(api-graphql): custom operation selection set on nested custom types #13078

Merged
merged 3 commits into from
Mar 8, 2024

Conversation

HuiSF
Copy link
Member

@HuiSF HuiSF commented Mar 4, 2024

Description of changes

  • Updated custom operation impl. to use pre-existing selection set generation utility function so it can handle nested custom types
  • Added unit tests against the nested custom types scenarios
  • Bump data schema packages versions to gain new implementations

Issue #, if available

Description of how you validated changes

  1. unit tests
  2. manual E2E tests in a sample app

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@HuiSF HuiSF requested review from a team as code owners March 4, 2024 18:22
@HuiSF HuiSF force-pushed the hui/fix/api-graphql/custom-operation-custom-types branch from c56af72 to 43e9b23 Compare March 4, 2024 20:03
stocaaro
stocaaro previously approved these changes Mar 5, 2024
Copy link
Member

@stocaaro stocaaro left a comment

Choose a reason for hiding this comment

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

Makes sense. I think all of the below are more nit than concern. Good to see this ship as is or with any attention to these comments.

Comment on lines +237 to +239
return `{${selectionSetIRToString(
defaultSelectionSetForNonModelWithIR(nonModel, modelIntrospection),
)}}`;
Copy link
Member

Choose a reason for hiding this comment

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

Exporting the default function to call it in passed into IRToString function makes me wonder if it would be better to export a function that combines the two functions instead of stacking the calls here.

import { isApiGraphQLConfig } from '../utils/isApiGraphQLProviderConfig';
import { generateEnumsProperty } from '../utils/generateEnumsProperty';
import { isApiGraphQLConfig } from '../utils/runtimeTypeGuards/isApiGraphQLProviderConfig';
import { generateEnumsProperty } from '../utils/clientProperties/generateEnumsProperty';
Copy link
Member

Choose a reason for hiding this comment

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

I'm a fan of grouping utils up into folders like this. Would it be valuable to have a folder level index that exports the sub-types instead of deep referencing them?

const model = modelIntrospection.nonModels[operation.type.nonModel];
return `{${modelishTypeSelectionSet(model)}}`;
const nonModel = modelIntrospection.nonModels[operation.type.nonModel];
return `{${selectionSetIRToString(
Copy link
Member

Choose a reason for hiding this comment

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

We're wrapping strings in surrounding curly brackets, {}, in several places. I find the character sequence `{${ a bit hard to read, which makes me wonder if a few extra chars for wrapInCurlyBrackets(x) might be more readable.

Not specific to this PR, but a thing I thought of.

@HuiSF HuiSF force-pushed the hui/fix/api-graphql/custom-operation-custom-types branch 3 times, most recently from 702f73f to e2d6f75 Compare March 7, 2024 19:01
Copy link
Member

@iartemiev iartemiev left a comment

Choose a reason for hiding this comment

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

LGTM.
As Aaron suggested, would be nice to import from a top-level utils/index.ts instead of sub-dirs, but that's non-blocking

@HuiSF
Copy link
Member Author

HuiSF commented Mar 8, 2024

Thanks if this is non-blocking I will open a separate PR to refactor further (also wanted to extra the selection set utils out from that long source file)

@HuiSF HuiSF force-pushed the hui/fix/api-graphql/custom-operation-custom-types branch from e2d6f75 to 2b026c2 Compare March 8, 2024 20:10
@HuiSF HuiSF merged commit 1570b12 into main Mar 8, 2024
30 checks passed
@HuiSF HuiSF deleted the hui/fix/api-graphql/custom-operation-custom-types branch March 8, 2024 20:22
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.

4 participants