0

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])
Yu-Lin Chen
  • 559
  • 5
  • 12

1 Answers1

0

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}))
Yu-Lin Chen
  • 559
  • 5
  • 12