Expected type 'GraphQLObjectType', got 'Type[Query]' instead
See original GitHub issueHello.
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.
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:
- Created 5 years ago
- Reactions:6
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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()
@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