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

"Expected value of type \"Visit\" but got: Visit." #599

Closed
threewordphrase opened this issue Mar 23, 2019 · 5 comments
Closed

"Expected value of type \"Visit\" but got: Visit." #599

threewordphrase opened this issue Mar 23, 2019 · 5 comments

Comments

@threewordphrase
Copy link

threewordphrase commented Mar 23, 2019

Hello, I have a very strange issue. Just playing around with GraphQL in an existing project. Here is my schema:

import graphene
from graphene_django.types import DjangoObjectType

from ops.models import Visit as VisitModel

class Visit(DjangoObjectType):
    class Meta:
        model = VisitModel

class Query(graphene.ObjectType):
    visits = graphene.List(Visit)

    def resolve_visits(self, info):
        return VisitModel.objects.all()

schema = graphene.Schema(query=Query)

Query:

{
  visits {
  	createdAt
  }
}

Output:

{
  "errors": [
    {
      "message": "Expected value of type \"Visit\" but got: Visit.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    },
    {
      "message": "Expected value of type \"Visit\" but got: Visit.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    },
    {
      "message": "Expected value of type \"Visit\" but got: Visit.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    },

FWIW, these are Proxy Models, not sure if that matters.

@zbyte64
Copy link
Collaborator

zbyte64 commented Mar 24, 2019

Possibly a recreation of #319 ; Right now basic proxy models are suppose to work, but expects VisitModel to be the base proxy. The test is also using the relay interface and some other params, perhaps we should duplicate the test without those extra params as you did here.

@abettke
Copy link

abettke commented Mar 27, 2019

To add to this, my team is also finding this same behavior. We use the following library versions. It only seems to occur on Types that are using a proxy model.

graphql-core==2.1
graphene==2.1.3
graphene-django==2.2.0

Debugging this, it looks like the issue is specifically arising from the PR #373.
At this line it is comparing the proxy to the concrete model. model is evaluating to the concrete_model whereas cls._meta.model is evaluating to the proxy model, which is causing the method to return false and throw the GraphQLError.

Also, to back up this, the problem seems to occur when it is a field referencing the proxy model as a foreign key.

Update. I've pushed a PR #603 to address this issue.

@stale
Copy link

stale bot commented Jun 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 11, 2019
@abettke
Copy link

abettke commented Jun 11, 2019

#603 addresses this issue.

@stale stale bot removed the wontfix label Jun 11, 2019
@stale
Copy link

stale bot commented Aug 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 10, 2019
@stale stale bot closed this as completed Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants