graphql-python / graphene-gae

GraphQL Support for Google AppEngine [DEPRECATED - Looking for maintainers]

Home Page:http://docs.graphene-python.org/projects/gae/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KeyProperty not showing up in schema

Trupal00p opened this issue · comments

Hi all, this library has a lot of promise nice work so far!

I've noticed that my KeyProperties aren't showing up when I inspect the resulting schema. Maybe there's something that I'm missing that to-be-completed docs would reveal?

the code I'm testing the library with:

Model Definition:

class AuthorizeNetConnection(ndb.Model):
    usr = ndb.KeyProperty(kind='CEUser')
    account_nickname = ndb.StringProperty(indexed=False)
    api_login_id = ndb.StringProperty(indexed=False)
    api_transaction_key = ndb.StringProperty(indexed=False)
    active = ndb.BooleanProperty(default=True)

Type Definition:

class ConnectionType(NdbObjectType):

    class Meta:
        model = datamodel.AuthorizeNetConnection

Introspection result:

{
  "invalid": false,
  "data": {
    "__type": {
      "name": "ConnectionType",
      "kind": "OBJECT",
      "fields": [
        {
          "name": "account_nickname"
        },
        {
          "name": "active"
        },
        {
          "name": "api_login_id"
        },
        {
          "name": "api_transaction_key"
        },
        {
          "name": "ndb_id"
        }
      ]
    }
  },
  "errors": []
}

Figured it out for those with the same question. You need to define the the model type that the keyproperty is linking to so that graphene_gae can do its magic. So, for my example above I just needed to add the below and all started working.

class CEUserType(NdbObjectType):

    class Meta:
        model = datamodel.CEUser

Yep :)