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

Relation selection and filtering #453

Merged
merged 3 commits into from
Oct 30, 2021

Conversation

ondratra
Copy link
Contributor

@ondratra ondratra commented Sep 2, 2021

affects: @joystream/hydra-cli, @joystream/hydra-indexer-gateway

This PR adds a new feature - filtering by properties from related entities (solves #444). Fixes #448. Theoretically, it could also positively affect performance for some queries due to their simplification (assuming the code is correct and they generate the same results).

A significant amount of work related to this PR was done to Warthog's BaseService in Joystream/warthog#3 . Changes in Hydra mainly consist of bumping Warthog dependency version and simplifying some WarthogBaseService queries that can now leverage new Warthog's features.

@Lezek123
Copy link
Contributor

Lezek123 commented Sep 2, 2021

This PR adds a new feature - filtering by properties from related entities

Just to clarify - the filtering was already working in most cases, there was just some problem with id_eq queries.

Test results

Olympia mappings

Tests were performed on branch Joystream/joystream#2547) after updating the dependencies

  • Issue Relationship filtering - schema inconsistencies #444:

    workers(where: { group: { id_eq: "storageWorkingGroup" } }) {
      id
    }
    

    FIXED!

    workers(where: { membership: { metadata: { name_eq: "Alice" } } }) {
      # ...
    }
    

    NOT FIXED (but afaik it's a non-blocking issue)

    query {
      workersConnection(where: { group: { id_eq: "forumWorkingGroup" } }) {
        totalCount
      }
    }
    

    FIXED!

There was another issue discovered during the tests, probably related to #449:

ERROR: Stopping the proccessor due to errors: {} name: TypeError, message: Cannot read property 'forum_thread_id' of undefined, stack: TypeError: Cannot read property 'forum_thread_id' of undefined
    at sanitizeNullCharacter (/joystream/node_modules/@joystream/hydra-processor/lib/db/subscribers.js:37:16)
    at sanitizeEntity (/joystream/node_modules/@joystream/hydra-processor/lib/db/subscribers.js:30:9)
    at SanitizationSubscriber.beforeInsert (/joystream/node_modules/@joystream/hydra-processor/lib/db/subscribers.js:11:9)

After commenting out sanitizeNullCharacter call in node_modules/@joystream/hydra-processor/lib/db/subscribers.js all tests passed succesfully.

Storage v2 mappings (Joystream/joystream#2547):

Testes were performed on branch Joystream/joystream#2582 after updating the dependencies.

affects: @joystream/hydra-cli, @joystream/hydra-indexer-gateway
@ondratra ondratra force-pushed the relation_selection_and_filtering branch from 9b33dc6 to 53cc45e Compare October 25, 2021 20:57
…dency update

affects: @joystream/hydra-cli, @joystream/hydra-indexer-gateway, @joystream/hydra-processor,
@joystream/hydra-typegen, sample
@ondratra
Copy link
Contributor Author

Recent PR changes include dependency updates and change from dependency on NPM packages from @dzlzv namespace to @joystream namespace.

Update in dependencies caused one weird error in variant filtering test.

The processor processed block 342
    1) should find by a variant filter

Disconnecting from the chain

  0 passing (42s)
  1 failing

  1) end-to-end transfer tests
       should find by a variant filter:
     Error: QueryBuilder parameter keys may only contain numbers, letters, underscores, or periods.-"account"."status"isTypeOf_eq-: {"response":{"errors":[{"message":"QueryBuilder parameter keys may only contain numbers, letters, underscores, or periods.-\"account\".\"status\"isTypeOf_eq-","locations":[{"line":3,"column":5}],"path":["accounts"],"extensions":{"code":"INTERNAL_SERVER_ERROR"}}],"data":null,"status":200,"headers":{}},"request":{"query":"\n  query {\n    accounts(where: { status_json: { isTypeOf_eq: \"Miserable\" } }) {\n      status {\n        __typename\n        ... on Miserable {\n          hates\n        }\n      }\n    }\n  }\n"}}
      at /mnt/work/Joystream/hydra/node_modules/graphql-request/src/index.ts:325:11
      at step (/mnt/work/Joystream/hydra/node_modules/graphql-request/dist/index.js:63:23)
      at Object.next (/mnt/work/Joystream/hydra/node_modules/graphql-request/dist/index.js:44:53)
      at fulfilled (/mnt/work/Joystream/hydra/node_modules/graphql-request/dist/index.js:35:58)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

The error was resolved by relying on the older typeorm version 0.2.34 and forcing it via resolutions directive in codegen generated packaged.json. Strangely enough, it seems that this test is working on Subsquid's fork of Hydra that is using typeorm v0.2.34, so we might remove the change to codegen when the forks are united.

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.

Problem when querying ManyToMany relationships in hydra-3.1.0-alpha.7
3 participants