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

KeyProperty not showing up in schema #22

Closed Trupal00p closed 8 years ago

Trupal00p commented 8 years ago

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": []
}
Trupal00p commented 8 years ago

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
ekampf commented 8 years ago

Yep :)