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

Add NonExposed parameter decorator #1395

Merged
merged 6 commits into from
Jun 20, 2023

Conversation

gonzalojaubert
Copy link
Contributor

@gonzalojaubert gonzalojaubert commented Apr 17, 2023

Description

Add a decorator to remove a parameter from GraphQL Schema

Changes

Checks

  • Project Builds
  • Project passes tests and checks
  • Updated documentation accordingly

@gonzalojaubert gonzalojaubert marked this pull request as draft April 17, 2023 13:43
@what-the-diff
Copy link

what-the-diff bot commented Apr 17, 2023

PR Summary

  • Updated Dependencies
    Upgraded @boostercloud/eslint-config and @boostercloud/framework-types dependencies to version 1.7.0
  • New Ignore Decorator
    Introduced a new decorator called "ignore" to mark parameters as ignored in GraphQL queries, mutations or subscriptions
  • BoosterConfig Property Addition
    Added a new property to the BoosterConfig class
  • Property Utilization
    The new property is now used in GraphQLMutationGenerator and GraphQLTypeInformer classes
  • Integration Test
    Implemented an integration test for this functionality in the schema command

@ghost
Copy link

ghost commented Apr 17, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@gonzalogarciajaubert gonzalogarciajaubert marked this pull request as ready for review June 14, 2023 15:27
@gonzalogarciajaubert
Copy link
Collaborator

/integration sha=eb84eb9

@github-actions
Copy link
Contributor

⌛ Integration tests are running...

Check their status here 👈

@gonzalojaubert gonzalojaubert changed the title Add ignore parameter decorator Add NonExposed parameter decorator Jun 16, 2023
@gonzalogarciajaubert
Copy link
Collaborator

/integration sha=b079792

@github-actions
Copy link
Contributor

⌛ Integration tests are running...

Check their status here 👈

@github-actions
Copy link
Contributor

❌ Oh no! Integration tests have failed

@github-actions
Copy link
Contributor

✅ Integration tests have finished successfully!

Copy link
Contributor

@alvaroloes alvaroloes left a comment

Choose a reason for hiding this comment

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

Approved. I just left two code improvements

fields: Array<PropertyMetadata>,
excludeProps?: Array<string>
): Array<PropertyMetadata> {
return excludeProps ? fields.filter((field: PropertyMetadata) => !excludeProps.includes(field.name)) : [...fields]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: We can just return the same array instead of making a copy.

Suggested change
return excludeProps ? fields.filter((field: PropertyMetadata) => !excludeProps.includes(field.name)) : [...fields]
return excludeProps ? fields.filter((field: PropertyMetadata) => !excludeProps.includes(field.name)) : fields

return methodName
}
const argumentNames = getFunctionArguments(target)
return argumentNames[parameterIndex!]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think using ! will throw if the value is undefined. I know that, supposedly, if methodName is undefined, then parameterIndex must not... but we can't be sure. My suggestion is to add a explicit throw here with a message that tells exactly that "we could not get field name information in {this class}, {this method name}, etc.".

That way, we would know instantly what the error is about, instead of needing to debug something like undefined can be used to index or, worse, fail silently and having an array of "non exposed fields" all filled with undefined 😂

@gonzalogarciajaubert
Copy link
Collaborator

/integration sha=bdf4b0a

@github-actions
Copy link
Contributor

⌛ Integration tests are running...

Check their status here 👈

@github-actions
Copy link
Contributor

✅ Integration tests have finished successfully!

@gonzalogarciajaubert gonzalogarciajaubert merged commit ef3c80f into boostercloud:main Jun 20, 2023
6 checks passed
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