angel-dart-archive / graphql

moved to angel-dart/angel/packages/graphql

Home Page:https://github.com/angel-dart/angel/tree/master/packages/graphql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include validation helpers

thosakwe opened this issue · comments

*This issue was automatically moved to: angel-dart/angel#202.

As of angel_validate v3, the way to validate things is now to use the type-safe Field and Form API's, so it might end up looking like this:

field(
  'createPost',
  resolve: validateGraphQL(
    Form(fields: [
      TextField('name').match(maxLength(255),
      TextField('text'),
      ListField('tags', isRequired: false).ofStrings(),
    ]),
    resolveViaServiceCreate(postService),
  ),
)

// There should also be a way to use a `Field` to read straight from GraphQL inputs:
var name = await nameField.readFromMap(inputs);

Because of the new major version of validate, this would be in a later version.