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

Schema.obj allows for fields to be an empty list, which causes a runtime error for clients #92

Open
sgrove opened this issue Jun 18, 2018 · 1 comment

Comments

@sgrove
Copy link

sgrove commented Jun 18, 2018

If fields for a GraphQL object type is empty, it'll cause an error to be thrown on the reference GraphQL implementation, so that this is effectively not valid:

let gen_TokenPaginationObj =
    Schema.(
      obj("TokenPagination", ~fields=_gen_forRecObjType => [])
    )

Perhaps there should be some validation function we can call at runtime to make sure we've constructed a valid GraphQL schema?

@andreas
Copy link
Owner

andreas commented Jun 19, 2018

I've considered having Schema.schema raise an exception in case of validation errors. Presumably creating a schema is something that happens once at "boot time", so it should be easy to catch invalid schemas with even the most primitive test suite. There are definitely more complex solutions (e.g. add a phantom type parameter to Schema.schema which is either unvalidated or validated -- then you can only execute queries on validated schemas), but I'm not sure it's worth it.

Could you be interested in adding one or more validations?

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

No branches or pull requests

2 participants