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

Bugfix model #17

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Bugfix model #17

wants to merge 10 commits into from

Conversation

pgrund
Copy link
Contributor

@pgrund pgrund commented Jul 14, 2021

finding correct graphqlmodel, if not there take "closest" parent (inheritance)

@pgrund pgrund marked this pull request as draft July 14, 2021 11:43
@pgrund pgrund marked this pull request as ready for review July 14, 2021 11:43
@dmytroyarmak
Copy link

@pgrund Could you please remove code styling changes in lib/types/baseOperator.ts and package.json from the PR?

@dmytroyarmak
Copy link

And could you also please add some tests for that change?

@pgrund
Copy link
Contributor Author

pgrund commented Jul 30, 2021

sorry, summer break ... will continue on this topic latest next week ...

@@ -24,7 +24,8 @@ export const createFilterType = (type: Function) => {
const typeGraphQLMetadata = getTypeGraphQLMetadataStorage();

const objectTypesList = typeGraphQLMetadata.objectTypes;
const graphQLModel = objectTypesList.find((ot) => types.includes(ot.target) && (typeGraphQLMetadata.inputTypes.findIndex(it => it.name === (ot.name + "Filter")) < 0))
const graphQLModels = objectTypesList.filter((ot) => types.includes(ot.target) && (typeGraphQLMetadata.inputTypes.findIndex(it => it.name === (ot.name + "Filter")) < 0));
const graphQLModel = graphQLModels.find(m => m.name === type.name) || graphQLModels.slice(-1).pop()

Choose a reason for hiding this comment

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

Although, it's not critical in this particular case, but it would be better to use graphQLModels[graphQLModels.length - 1] to get last value of array instead of graphQLModels.slice(-1).pop() (to avoid redundant copying of an array)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice catch .. leftover from some intermediate steps ...

Copy link

@dmytroyarmak dmytroyarmak left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good 👍

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.

None yet

2 participants