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

Better FieldPath argument validation #10

Open
5 tasks
0xMochan opened this issue Mar 3, 2023 · 0 comments
Open
5 tasks

Better FieldPath argument validation #10

0xMochan opened this issue Mar 3, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@0xMochan
Copy link
Collaborator

0xMochan commented Mar 3, 2023

Is your feature request related to a problem? Please describe. Yes. When constructing FieldPaths with arguments, any extra arguments (i.e.: arguments which don't exist in the subgraph schema) are silently ignored, leading to harder debugging in case of errors like typos.

Moreover, although the values of real arguments are type-checked, the exceptions are cryptic and uninformative.

Describe the solution you'd like When constructing FieldPaths with arguments, for each argument, Subgrounds should check whether:

  1. The argument exists in the schema
  2. The type of the argument's value matches the type indicated in the schema
  3. If using relative FieldPaths (e.g.: subgraph.Query.entities(orderBy=subgraph.Entity.field)), validate that the field type on which that argument is applied matches the type of the relative FieldPath (i.e.: the type of entities matches the Entity object).

Error messages should also be clear and informative. E.g.: "X is not a valid value for argument orderBy".

Describe alternatives you've considered None

Additional context None

Implementation checklist

  • Validate arguments
    • Check whether the argument exists in the schema
    • Check whether the value given to the argument matches the type specified in the schema
    • Check whether relative FieldPaths match the type of the field
  • Improved error messages

Originally from: cvauclair

@0xMochan 0xMochan added the enhancement New feature or request label Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant