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

Support for specifying Node ID relations as condition inputs #8

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

Conversation

marshall007
Copy link
Collaborator

@marshall007 marshall007 commented Jun 3, 2019

TODO

  • add tests

Future Work

  • refactor into separate plugins
  • handle null case on NodeID conditions
  • properly error when the specified NodeID is invalid
    • wrong table type
    • mismatch between non-NodeID conditions

@marshall007 marshall007 requested a review from benjie June 3, 2019 19:48
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated

for (const identifier of fk.fromNodeId(nodeId)) {
queryBuilder.where(
sql.fragment`${alias}.${sql.identifier(identifier.columnName)} = ${sql.value(identifier.value)}`
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 not sure if this should use sql.value or gql2pg

@marshall007
Copy link
Collaborator Author

@benjie I've added tests, please review again when you have a chance. I think I'm gonna leave any further refactoring (splitting into multiple plugins) for a later time. We have a need for these changes in our current project so I'd just like to get it merged ASAP.

@marshall007
Copy link
Collaborator Author

@benjie I have opened up a separate PR to this branch which converts the new condition inputs to array arguments. The desire for this popped up basically immediately once we started using it.

Need help understanding why the updated test is failing on that branch with GraphQLError: Cannot read property 'fragment' of undefined.

@marshall007
Copy link
Collaborator Author

Fixed the failing test and merged that PR. Just need to make sure array NodeID condition args seem like a sane default default to you @benjie.

@marshall007 marshall007 changed the title WIP: support for specifying Node ID relations as condition inputs Support for specifying Node ID relations as condition inputs Jun 4, 2019
.vscode/settings.json Outdated Show resolved Hide resolved
package-lock.json Outdated Show resolved Hide resolved
src/__tests__/__snapshots__/schema-base.test.ts.snap Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@@ -307,6 +307,9 @@ input ItemCondition {

\\"\\"\\"Checks for equality with the object’s \`createdAt\` field.\\"\\"\\"
createdAt: Datetime

\\"\\"\\"The globally unique \`ID\` to be used in selecting a single \`Person\`.\\"\\"\\"
personByPersonOrganizationIdAndPersonIdentifier: [ID!]
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 still not comfortable with this naming for an array field, I'd prefer something like personByPersonOrganizationIdAndPersonIdentifierIsOneOf or In or IsIn or ContainedIn.

Incidentally the description doesn't match (missing plural).

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.

2 participants