graphql-python / graphene-gae

GraphQL Support for Google AppEngine [DEPRECATED - Looking for maintainers]
http://docs.graphene-python.org/projects/gae/en/latest/
BSD 3-Clause "New" or "Revised" License
117 stars 14 forks source link

Expected value of type "UserType" but got: User #36

Closed hussaini closed 6 years ago

hussaini commented 6 years ago

Hi,

I try to develop simple GraphQL with graphene-gae using flask framework. But I'm getting error when I try to execute the query. The query is:

query {
    allUsers {
        username,
        email
    }
}

and the error message is Expected value of type \"UserType\" but got: User

Here is my snippet of code

user.py

from google.appengine.ext import ndb

class User(ndb.Model):
    username = ndb.StringProperty()
    email = ndb.StringProperty()
    password = ndb.StringProperty()
    created_at = ndb.DateTimeProperty(auto_now_add=True)
    updated_at = ndb.DateTimeProperty(auto_now=True)

schema.py

import graphene

from graphene_gae import NdbObjectType
from user import User

class UserType(NdbObjectType):
    class Meta:
        model = User

class Query(graphene.ObjectType):
    all_users = graphene.List(UserType)

    def resolve_all_users(self, info):
        return User.query()

schema = graphene.Schema(query=Query)

I'm using graphene-gae 2.0.dev2017073101

ekampf commented 6 years ago

Hey @hussainizulkifli Can you try using the latest version? (2.0.0)

hussaini commented 6 years ago

Hi @ekampf , sorry for late reply.

I have change to version 2.0.0 and it works fine.

Thanks!

steinnat commented 5 years ago

Why does this error occur?