How fix error: “Expected value of type \”*GQL\“ but got: *.”?
See original GitHub issueHello! At the data schema level in SQLAlchemy, all tables are linked through a relationship. I have the following GraphQL data schema:
class CategoryGQL(SQLAlchemyObjectType):
class Meta:
proxy = True
description = "Table of category"
model = CategoryModel
interfaces = [relay.Node]
class DOOPGQL(SQLAlchemyObjectType):
class Meta:
proxy = True
description = "Table of DOOP"
model = DOOPModel
interfaces = (relay.Node,)
class DirectionGQL(SQLAlchemyObjectType):
class Meta:
description = "Table of direction"
model = DirectionModel
interfaces = [relay.Node]
class Category_DOOPGQL(SQLAlchemyObjectType):
class Meta:
description = "Category and Doop relationship table"
model = Category_DOOP_Model
interfaces = (relay.Node,)
I also implement this resolver. I got the error: Received incompatible instance, if I didn’t use lambda with the first parameter graphene.List():
class AdvancedSearch(ObjectType):
age = List(graphene.NonNull(graphene.String)) # [Array!]
direction = List(graphene.NonNull(graphene.String)) # [Array!]
ovz = graphene.Boolean()
doops = graphene.List(lambda: graphene.List(DOOPGQL),ovz=ovz,age=age,direction=direction)
def resolve_doops(self,info):
query = db.query(DOOP,Direction,Category,Category_DOOP)
query = query.filter_by(ovz=self.ovz)
query = query.join(Direction, Direction.id_cluster == DOOP.id_cluster)
query = query.filter(Direction.name.in_(self.direction))
query = query.join(Category_DOOP, Category_DOOP.id_doop == DOOP.id)
query = query.join(Category, Category_DOOP.id_category == Category.id)
query = query.filter(Category.age_max.in_(self.age),Category.age_min.in_(self.age))
query = query.all()
return query
I get this answer:
"errors": [
{
"message": "Expected value of type \"DOOPGQL\" but got: Direction.",
"locations": [
{
"line": 3,
"column": 5
}
]
},
{
"message": "Expected value of type \"DOOPGQL\" but got: Category.",
"locations": [
{
"line": 3,
"column": 5
}
]
},
{
"message": "Expected value of type \"DOOPGQL\" but got: Category_DOOP.",
"locations": [
{
"line": 3,
"column": 5
}
]
}
]
I tried different ways. I changed the names of the tables in lambda: graphene. List(DOOPGQL), but I had 1\4 tables working. Maybe I’m returning a request, but not in the format that GraphQL is waiting for?
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
How fix error: “Expected value of type \”*GQL\“ but got
Hello! At the data schema level in SQLAlchemy, all tables are linked through a relationship. I have the following GraphQL data schema:
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
@chrisberks Today I made an attempt to rewrite the filter. I found that for the request format I needed, I needed to use the interface. Following the instructions https://docs.graphene-python.org/en/latest/types/interfaces/ I implemented the following class:
Right now, the resolver looks like this:
I also noticed a bug that the answer contains 2 objects at the time of the request:
doop
andevent
, but when I debug, there is only onedoop
object in theinstance
, and the event object simply disappears from the finalanswer
selection. Unfortunately, after all my attempts, I got this answer:I would appreciate any ideas and thoughts, maybe they will help you find the right way to solve the problem.
Thank you for that @thorin072, happy to help!