0

I get this error :

"errors": [
    {
      "message": "Type Query must define one or more fields."
    }
  ]

when I run my query :

{
  user{

   _id 
    name
    username
    password
    email
    date_inscription
    profession

  }
}

I have the same example then https://blog.cloudboost.io/a-crud-app-with-apollo-graphql-nodejs-express-mongodb-angular5-2874111cd6a5

LS_
  • 6,763
  • 9
  • 52
  • 88

1 Answers1

0

This error indicates that your query doesn't return any fields. Make sure that under graphql/queries/user/user.js you have at least one field defined like this:

const UserListType = new GraphQLObjectType({ name: 'UserList', fields() { return { id: { type: GraphQLInt, description: "Unique identifier of the User" } } } })

The other piece to check is that you have properly exported the query in graphql/queries/index.js like this:

// Users
const listUsers = require('./user/listUsers')

module.exports = {

  // Users
  listUsers
} 
Aaron Henderson
  • 1,840
  • 21
  • 20