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

Uncaught Error: Unsupported field type: Boolean at invariant #335

Closed
cesarve77 opened this issue Aug 22, 2017 · 2 comments
Closed

Uncaught Error: Unsupported field type: Boolean at invariant #335

cesarve77 opened this issue Aug 22, 2017 · 2 comments
Assignees
Labels
Type: Feature New features and feature requests

Comments

@cesarve77
Copy link
Contributor

cesarve77 commented Aug 22, 2017

if I use type Boolean in my graphql schema and AutoField i get this error in my browser :
Uncaught Error: Unsupported field type: Boolean at invariant

example:

const type=buildSchema(`
     type SignUp {
         name:          String!
         familyName:    String!
         email:         String!
         password:      String!
         terms:         Boolean!
     }
 # This is required by buildASTSchema
 type Query { anything: ID }
 `).getType('SignUp')


const schema = new GraphQLBridge(type, function (model) { .....

example :

<AutoField name="terms" type='checkbox' label="I agree to adhere with terms "/>

I can solved this problem

  1. Or using Int in the schema
  2. or using CheckBox component instead of AutoField
  3. or adding property component=CheckBox in AutoField

Maybe adding this line code to https://github.com/vazco/uniforms/blob/master/packages/uniforms/src/GraphQLBridge.js

can solve the issue

` getType (name) {
const fieldType = this.getField(name).type;

    if (fieldType instanceof graphql.GraphQLList)            return Array;
    if (fieldType instanceof graphql.GraphQLObjectType)      return Object;
    if (fieldType instanceof graphql.GraphQLInputObjectType) return Object;
    if (fieldType instanceof graphql.GraphQLScalarType) {
        if (fieldType.name === 'Int')    return Number;
        if (fieldType.name === 'Float')  return Number;
        if (fieldType.name === 'String') return String;
    ++if (fieldType.name === 'Boolean') return Boolean;
    }

    return fieldType;
}

`

@radekmie radekmie self-assigned this Aug 22, 2017
@radekmie radekmie added the Type: Feature New features and feature requests label Aug 22, 2017
@radekmie
Copy link
Contributor

I'm surprised that it came out that late. Do you want to submit a PR with it?

@cesarve77
Copy link
Contributor Author

cesarve77 commented Aug 22, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New features and feature requests
Projects
Archived in project
Development

No branches or pull requests

2 participants