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: integrate async-graphql into GraphQL API #877

Merged
merged 16 commits into from
May 17, 2023

Conversation

deekerno
Copy link
Contributor

@deekerno deekerno commented May 9, 2023

Description

Following the switch from graphql-parser to async-graphql-parser for our parsing needs, this PR further integrates available features from GraphQL in order to improve the developer experience.

Specifically, it adds the following features:

Other GraphQL-idiomatic issues will be addressed in a subsequent PR.

Testing steps

CI should pass.

Manual Testing

The main value add in this PR is introspection support for any user-defined schema in the GraphQL playground. To test this with the block explorer example:

  • Ensure the DB is clear and build the required WASM module.
  • cargo run --bin fuel-indexer -- run --manifest examples/block-explorer/explorer-indexer/explorer_indexer.manifest.yaml --run-migrations --fuel-node-host beta-3.fuel.network --fuel-node-port 80
  • Open up the playground: http://localhost:29987/api/playground/fuel_examples/explorer_indexer
  • Open the Docs and Schema tabs on the side; you should see that there is now information that helps a user to write their queries.
  • Begin typing a query; you should see suggestions for usable fields begin to appear. If not, you can press Option+Space (if on a Mac) to bring up the suggestion dropdown, if applicable at the current cursor location.

Changelog

  • Add dynamic schema construction in new dynamic.rs module
  • Add full auto-generated documentation for GraphQL playground

@deekerno deekerno force-pushed the deekerno/integrate-async-graphql branch from ea2edb0 to 42cd935 Compare May 13, 2023 00:25
@deekerno deekerno marked this pull request as ready for review May 16, 2023 14:48
@deekerno deekerno requested a review from a team May 16, 2023 14:48
@ra0x3
Copy link
Contributor

ra0x3 commented May 16, 2023

@deekerno Looks ok but needs to be rebased on master? I still see QueryRoot in the schema.

@ra0x3 ra0x3 requested review from ra0x3 and removed request for a team May 16, 2023 16:26
Copy link
Contributor

@ra0x3 ra0x3 left a comment

Choose a reason for hiding this comment

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

@deekerno

  • Testing steps worked
  • Left a lot of comments about style and readability

packages/fuel-indexer-graphql/src/dynamic.rs Show resolved Hide resolved
packages/fuel-indexer-graphql/src/dynamic.rs Show resolved Hide resolved
packages/fuel-indexer-graphql/src/dynamic.rs Outdated Show resolved Hide resolved
packages/fuel-indexer-graphql/src/dynamic.rs Show resolved Hide resolved
packages/fuel-indexer-graphql/src/dynamic.rs Show resolved Hide resolved
packages/fuel-indexer-graphql/src/dynamic.rs Show resolved Hide resolved
packages/fuel-indexer-graphql/src/dynamic.rs Outdated Show resolved Hide resolved
packages/fuel-indexer-graphql/src/dynamic.rs Outdated Show resolved Hide resolved
packages/fuel-indexer-graphql/src/dynamic.rs Outdated Show resolved Hide resolved
packages/fuel-indexer-graphql/src/dynamic.rs Outdated Show resolved Hide resolved
@deekerno deekerno force-pushed the deekerno/integrate-async-graphql branch from b208313 to b33a0ac Compare May 16, 2023 20:14
@deekerno deekerno force-pushed the deekerno/integrate-async-graphql branch from 89ca117 to 05ee354 Compare May 16, 2023 20:33
@deekerno deekerno requested a review from ra0x3 May 16, 2023 21:00
Copy link
Member

@luizstacio luizstacio left a comment

Choose a reason for hiding this comment

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

@deekerno I was not able to run this PR locally the indexer returns a error, I'm running it using a local postgres database;

2023-05-16T21:45:21.076546Z ERROR fuel_indexer::database: 105: TypeId(-3434938465688289560) not found in tables: {}
2023-05-16T21:45:21.076969Z ERROR fuel_indexer::database: 105: TypeId(4447527238938559951) not found in tables: {}
2023-05-16T21:45:21.077348Z ERROR fuel_indexer::database: 105: TypeId(-1100053459620569284) not found in tables: {}
2023-05-16T21:45:21.077723Z ERROR fuel_indexer::database: 105: TypeId(-1100053459620569284) not found in tables: {}
2023-05-16T21:45:21.078104Z ERROR fuel_indexer::database: 105: TypeId(5652593424517424978) not found in tables: {}
2023-05-16T21:45:21.078504Z ERROR fuel_indexer::database: 105: TypeId(-8806802248022301227) not found in tables: {}

I saw this error before when I was doing the PoC where the issue was fixed here. Do I need to change something on my env?

@deekerno
Copy link
Contributor Author

@deekerno I was not able to run this PR locally the indexer returns a error, I'm running it using a local postgres database;


2023-05-16T21:45:21.076546Z ERROR fuel_indexer::database: 105: TypeId(-3434938465688289560) not found in tables: {}

2023-05-16T21:45:21.076969Z ERROR fuel_indexer::database: 105: TypeId(4447527238938559951) not found in tables: {}

2023-05-16T21:45:21.077348Z ERROR fuel_indexer::database: 105: TypeId(-1100053459620569284) not found in tables: {}

2023-05-16T21:45:21.077723Z ERROR fuel_indexer::database: 105: TypeId(-1100053459620569284) not found in tables: {}

2023-05-16T21:45:21.078104Z ERROR fuel_indexer::database: 105: TypeId(5652593424517424978) not found in tables: {}

2023-05-16T21:45:21.078504Z ERROR fuel_indexer::database: 105: TypeId(-8806802248022301227) not found in tables: {}

I saw this error before when I was doing the PoC where the issue was fixed here. Do I need to change something on my env?

That kind of error typically goes away when the WASM modules are freshly compiled. If that doesn't work, then you may need to refresh the database.

@luizstacio
Copy link
Member

@deekerno I was not able to run this PR locally the indexer returns a error, I'm running it using a local postgres database;


2023-05-16T21:45:21.076546Z ERROR fuel_indexer::database: 105: TypeId(-3434938465688289560) not found in tables: {}

2023-05-16T21:45:21.076969Z ERROR fuel_indexer::database: 105: TypeId(4447527238938559951) not found in tables: {}

2023-05-16T21:45:21.077348Z ERROR fuel_indexer::database: 105: TypeId(-1100053459620569284) not found in tables: {}

2023-05-16T21:45:21.077723Z ERROR fuel_indexer::database: 105: TypeId(-1100053459620569284) not found in tables: {}

2023-05-16T21:45:21.078104Z ERROR fuel_indexer::database: 105: TypeId(5652593424517424978) not found in tables: {}

2023-05-16T21:45:21.078504Z ERROR fuel_indexer::database: 105: TypeId(-8806802248022301227) not found in tables: {}

I saw this error before when I was doing the PoC where the issue was fixed here. Do I need to change something on my env?

That kind of error typically goes away when the WASM modules are freshly compiled. If that doesn't work, then you may need to refresh the database.

After a cargo clean it work's. Thanks for the help.

Why we have this approach? It looks like a easy thing to break as force users to know about cleaning to make it work, maybe this data should be gather from the database. For sure is not something to be cover on this PR as is not related.

Copy link
Member

@luizstacio luizstacio left a comment

Choose a reason for hiding this comment

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

Functionality wise is looking good. Thanks for this changes. ✅

@deekerno
Copy link
Contributor Author

@deekerno I was not able to run this PR locally the indexer returns a error, I'm running it using a local postgres database;


2023-05-16T21:45:21.076546Z ERROR fuel_indexer::database: 105: TypeId(-3434938465688289560) not found in tables: {}

2023-05-16T21:45:21.076969Z ERROR fuel_indexer::database: 105: TypeId(4447527238938559951) not found in tables: {}

2023-05-16T21:45:21.077348Z ERROR fuel_indexer::database: 105: TypeId(-1100053459620569284) not found in tables: {}

2023-05-16T21:45:21.077723Z ERROR fuel_indexer::database: 105: TypeId(-1100053459620569284) not found in tables: {}

2023-05-16T21:45:21.078104Z ERROR fuel_indexer::database: 105: TypeId(5652593424517424978) not found in tables: {}

2023-05-16T21:45:21.078504Z ERROR fuel_indexer::database: 105: TypeId(-8806802248022301227) not found in tables: {}

I saw this error before when I was doing the PoC where the issue was fixed here. Do I need to change something on my env?

That kind of error typically goes away when the WASM modules are freshly compiled. If that doesn't work, then you may need to refresh the database.

After a cargo clean it work's. Thanks for the help.

Why we have this approach? It looks like a easy thing to break as force users to know about cleaning to make it work, maybe this data should be gather from the database. For sure is not something to be cover on this PR as is not related.

It's happens sometimes when there are large changes to the underlying schema. We have an outstanding issue for indexer migrations; we'll need to get together and flesh out the process for that.

@deekerno deekerno enabled auto-merge (squash) May 17, 2023 14:10
@deekerno deekerno merged commit 544a42a into master May 17, 2023
@deekerno deekerno deleted the deekerno/integrate-async-graphql branch May 17, 2023 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants