question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expected type 'GraphQLObjectType', got 'Type[Query]' instead

See original GitHub issue

Hello.

Django 2.0.7, Python 3.6.1

I get some strange warning at PyCharm 2018.2:

Expected type ‘GraphQLObjectType’, got ‘Type[Query]’ instead …

Inspection info: This inspection detects type errors in function call expressions. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Types of function parameters can be specified in docstrings or in Python 3 function annotations.

screen shot 2018-07-28 at 20 24 23

But everything is working great!

# core/schema.py

import graphene
from projects.schema import Query as ProjectQuery

class Query(ProjectQuery, graphene.ObjectType):
    pass

schema = graphene.Schema(query=Query)

# projects/schema.py

import graphene
from graphene_django.types import DjangoObjectType
from .models import Project

class ProjectType(DjangoObjectType):
    class Meta:
        model = Project
        interfaces = (graphene.Node,)

class Query(graphene.ObjectType):
    all_projects = graphene.List(ProjectType)

    def resolve_all_projects(self, info, **kwargs):
        return Project.objects.all()

What’s wrong? How to solve it? Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:5

github_iconTop GitHub Comments

5reactions
csjycommented, Mar 29, 2020

2019.3 still has this warning issue. schema = graphene.Schema(query=Query, mutation=Mutation) Expected type ‘ObjectType’, got ‘Type[Query]’ instead Strange enough only Query does it, the Mutation type is ok.

The types: class Query(graphene.ObjectType): actor = graphene.Field(ActorType, id=graphene.Int()) movie = graphene.Field(MovieType, id=graphene.Int()) actors = graphene.List(ActorType) movies = graphene.List(MovieType) …methods are removed for brevity.

class Mutation(graphene.ObjectType): create_actor = CreateActor.Field() update_actor = UpdateActor.Field() create_movie = CreateMovie.Field() update_movie = UpdateMovie.Field()

5reactions
MewXcommented, Sep 23, 2018

@jayhale the codes still run, and yes, it is just a warning message from PyCharm.

P.S. problem still exists in the latest PyCharm 2018.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't have Input Types with nested fields in GraphQL. Error
SchemaError: Expected type 'OrderUnitInput' to be a GraphQLInputType, but it wasn't! Was a type only permitted for object types incorrectly used ...
Read more >
GraphQL schema basics - Apollo GraphQL Docs
This schema defines a hierarchy of types with fields that are populated from your back-end data stores. The schema also specifies exactly which...
Read more >
Schemas and Types - GraphQL
Character is a GraphQL Object Type, meaning it's a type with some fields. Most of the types in your schema will be object...
Read more >
Resolvers | NestJS - A progressive Node.js framework
Instead, we use TypeScript decorators to generate the SDL from TypeScript class ... Most of the definitions in a GraphQL schema are object...
Read more >
GraphQL: Mapping Error Messages to Generic Error Codes
Expected value of type "${inspect(type)}", found ${print(node)}. ... was removed in graphql-js@16.0.0 please return type name instead.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found