-
Notifications
You must be signed in to change notification settings - Fork 933
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
Add schema validation, require @entity in schema types #322
Conversation
Note: We should update the docs as part of this, to make sure people are aware of the introduction of |
In bad need of a rebase. |
This function should be used to reject subgraphs with invalid schemas.
7488a5a
to
2910f5a
Compare
We'll figure something out for interfaces later.
2910f5a
to
60a4bd1
Compare
@leodasvacas Done. Care to take another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart from minor comment. It'd be good to give the team a heads up and also update our adchain and decentraland subgraphs, so nobody gets a bad surprise when trying to demo something at ETHBerlin.
core/src/subgraph/provider.rs
Outdated
Err(e) => future::err::<_, SubgraphProviderError>( | ||
SubgraphProviderError::SchemaValidationError(e), | ||
), | ||
_ => future::ok::<_, _>(subgraph), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These turbofishes seems uncessary, also I wonder If we could just use Err
and Ok
instead of err
and ok
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You were right. Updated!
@leodasvacas Totally agree. I'll get PRs ready for all public subgraphs + docs before we merge this. |
Resolves #236. Depends on #320. Last puzzle piece in finishing #279.
This makes
@entity
mandatory on alltype
definitions in subgraph schemas. If we later want to distinguish between embeddable/inline types that are not represented as entities, we can relax this requirement again. (In that case we should e.g. verify that the inline types are actually referenced anywhere.)Subgraph schemas are now validated (with the above being checked) when subgraphs are deployed. If a subgraph schema fails to validate, the subgraph is rejected.
Now that it's mandator, we can use the
@entity
directive to properly collect entity types involved in subscription queries, and only subscribe to entity change events from the store for these entities. For example, the subscriptionwould result in a store subscription for
[(<subgraph ID>, Meme)]
. The subscriptionwould result in a store subscription for
[(<subgraph ID>, Meme), (<subgraph ID>, User)]
.