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

Can someone help me setting up graphql with this lib? #50

Closed
e200 opened this issue May 29, 2018 · 0 comments
Closed

Can someone help me setting up graphql with this lib? #50

e200 opened this issue May 29, 2018 · 0 comments

Comments

@e200
Copy link

e200 commented May 29, 2018

I'm following the readme example with my already created model:

const Model = require('../model')

class File extends Model {
  static get tableName()
  {
    return 'files'
  }

  static jsonSchema()
  {
    return {
      type: 'object',
      require: ['name'],
      properties: {
        id: { type: 'integer' },
        name: { type: 'string' },
        path: { type: 'string' },
        description: { type: 'string' }
      }
    }
  }
}

module.exports = File

This is how I'm setting up the GraphQL:

const { builder } = require('objection-graphql')
const graphql = require('express-graphql')
const file = require('../models/file')

const schema = builder()
          .model(file)
          .build()

        app.use('/graphql', graphql({
          schema: schema,
          graphiql: true
        }))

When I run this on graphiQL:

{
  Files(orderBy: id) {
    name
  }
}

this is what I got:

{
  "errors": [
    {
      "message": "Enum type FilesPropertiesEnum must define one or more values.\n\nType Files must define one or more fields."
    }
  ]
}

What I'm doing wrong?

@e200 e200 closed this as completed May 30, 2018
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

1 participant