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: avoid name collision on java model build step #700

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

dpilch
Copy link
Member

@dpilch dpilch commented Sep 14, 2023

Description of changes

Avoid name collision on Java model build step by adding Build if name is used by a type.

See #695 for details.

It is still possible for a collision to occur if the model has a second type that includes Build.

type TutorialStep {
  position: Int!
  text: String!
}

type TutorialBuild {
  position: Int!
  text: String!
}

type MyObject @model {
  id: ID!
  tutorial: [TutorialStep]
  tutorialBuild: [TutorialBuildStep]
}

We could add another layer of checks or use a randomly generated string, but I think this case is so rare that it should be ok.

Issue #, if available

Resolves #695

Description of how you validated changes

Unit tests

Checklist

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

@dpilch dpilch requested a review from a team as a code owner September 14, 2023 15:57
const stepInterfaceName = `${pascalCaseFieldName}Step`;

if (types.has(stepInterfaceName)) {
return `${pascalCaseFieldName}BuildStep`;
Copy link
Contributor

Choose a reason for hiding this comment

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

This could still collide if for a model A, there are AStep and ABuildStep in the fields. But it should be a rare case. The implementation is enough to fix the issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that this case would be so rare that this fix should be sufficient.

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.

GraphQLResponse.Error - SubSelectionRequired using generated models to query simple schema
3 participants