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

enhancement: add support for unindexable types #943

Merged
merged 10 commits into from
May 23, 2023

Conversation

ra0x3
Copy link
Contributor

@ra0x3 ra0x3 commented May 22, 2023

  • Please add proper labels
  • If there is an issue associated with this PR, please link the issue (right-hand sidebar)
  • If there is not an issue associated with this PR, add this PR to the "Fuel Indexer" project (right-hand sidebar)

Description

  • PR adds support for a @norelation directive
    • Applying this directive to any field on an object renders the entire object as NoRelation, which means the object is stored as Json
      • I chose Json over Blob because I think it might be easier to extract the item into an object
        • This will definitely require a second pass later
  • PR also moves some code around (moves serialize and deserialize from fuel-indexer-schema to fuel-indexer-lib)

Testing steps

  • Test was added so CI should pass
  • Build assets bash scripts/utils/build_test_wasm_module.bash
  • Start a local fuel node cargo run -p fuel-node --bin fuel-node
  • Start the web API cargo run -p web-api --bin web-api
  • Start the service with the test indexer
cargo run --bin fuel-indexer -- run --manifest packages/fuel-indexer-tests/components/indices/fuel-indexer-test/fuel_indexer_test.yaml --run-migrations
  • Trigger some data curl -X POST http://localhost:8000/block
  • Open your playground http://localhost:29987/api/playground/fuel_indexer_test/index1
  • Make the following query:
query {
  usesnotableentity {
    id
    name
    no_table
  }
}
  • Should see your type come back as JSON
{
  "data": [
    {
      "id": 1,
      "name": "hello world",
      "no_table": {
        "name": "norelation",
        "size": 1
      }
    }
  ]
}
  • Note that the item NoRelationEntity already comes back as an object straight from the DB, so no further deserialization is needed

Changelog

  • enhancement: add support for a @norelation directive that does not create SQL tables for entities

@ra0x3 ra0x3 added enhancement fuel-explorer This PR is directly related to the block explorer work in progress labels May 22, 2023
@ra0x3 ra0x3 self-assigned this May 22, 2023
@ra0x3 ra0x3 marked this pull request as draft May 22, 2023 18:27
@ra0x3 ra0x3 changed the title Rashad/940 unindexable objects 1 enhancement: add support for unindexable types May 22, 2023
@ra0x3 ra0x3 marked this pull request as ready for review May 23, 2023 14:34
Copy link
Contributor

@deekerno deekerno left a comment

Choose a reason for hiding this comment

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

Functionality looks good; the latest changes from master need to be integrated as the playground shows an error and the docs/schema don't load. But I'm sure they'll work after updating.

Left a couple of comments about readability.

packages/fuel-indexer-schema/src/utils.rs Outdated Show resolved Hide resolved
packages/fuel-indexer-macros/src/schema.rs Outdated Show resolved Hide resolved
packages/fuel-indexer-macros/src/schema.rs Outdated Show resolved Hide resolved
@ra0x3 ra0x3 requested a review from deekerno May 23, 2023 20:23
@ra0x3 ra0x3 merged commit c1d2897 into master May 23, 2023
43 checks passed
@ra0x3 ra0x3 deleted the rashad/940-unindexable-objects-1 branch May 23, 2023 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fuel-explorer This PR is directly related to the block explorer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for the creation of GraphQL objects without creating the subsequent tables from those objects
2 participants