How to get the compiled raw sql command from the graphQL
with SQLAlchemy
? I did the search but no luck :(
schema.py
class RecordType(SQLAlchemyObjectType):
class Meta:
model = Record
interfaces = (graphene.relay.Node, )
class Query(graphene.ObjectType):
node = graphene.relay.Node.Field()
record = graphene.Field(RecordType, id=graphene.Int())
def resolve_record(self, info, **args):
id = args.get('id')
return RecordType.get_query(info).get(id)
schema = graphene.Schema(query=Query, types=[RecordType])
Well, I just found the way, reference from https://stackoverflow.com/a/36141722/9041712
query = RecordType.get_query(info)
print(query.statement.compile(compile_kwargs={"literal_binds": True}))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.