You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see that the graphiql interface is able to introspect the schema, but I am not sure how you would export the schema form python. I see the introspect function on the Schema object, but that simply returns the objects from the type_map.
@ashinohara I've fixed the introspection method in the schema.
Just update your graphene package to 0.1.3 version and run schema.introspect() in your graphene.Schema:
importjsonschema=graphene.Schema(....)
introspection_dict=schema.introspect()
# Print the schema in the consoleprintjson.dump(introspection_dict)
# Or save the schema into some fileopen('schema.json', ‘w’) asfp:
json.dump(introspection_dict, fp)
Reacted by Sina, dan-klasson, Yurii Rabeshko, Jeongho Jeong, Youngwook Kim, Adnan, Aleksandr Kolodeev, matt bark, Tim Urista, Andreas Klintberg and 7 more
Reacted by Adnan and Marek Hanuš
Reacted by Yurii Rabeshko, Adnan, Tim Urista, Ali Heydari, Andreas Klintberg, Maksim Soltan and Chris Vouga
@syrusakbary Hi, each time I generate GQL schema, some fields' order changes.
Any idea on how I generate it, to be in the same order?
My goal is to trace schema changes in git.
Activity
Use last version of graphql-core. Fixed introspection #3
syrusakbary commentedon Oct 9, 2015
@ashinohara I've fixed the introspection method in the schema.
Just update your graphene package to
0.1.3version and runschema.introspect()in yourgraphene.Schema:syrusakbary commentedon Oct 9, 2015
Thanks @jhgg for showing me the way 😉
jhgg commentedon Oct 9, 2015
No problem!
Merge pull request graphql-python#3 from sjhewitt/sqlautils-json
yakneens commentedon Oct 18, 2017
This should be automatically exposed by Graphene as a query that returns the file.
isakal commentedon Feb 2, 2020
If you want to get schema in GraphQL SDL format:
Curiouspaul1 commentedon Dec 29, 2020
How does one save this to a file like schema.graphql or .gql
5chulzi commentedon Feb 17, 2021
Here you go:
This works, because the schema class uses the
def __str__(self)method to return the string representation of the underlying graphql schema.guiklimek commentedon Oct 21, 2021
Using the command: https://docs.graphene-python.org/projects/django/en/latest/introspection/
krish7919 commentedon Nov 26, 2021
(Sorry to comment on a closed issue but this seems to be the right place)
Is there a way for graphene to query Postgres directly and generate an SDL file ?
msalah0e commentedon Oct 22, 2022
@syrusakbary Hi, each time I generate GQL schema, some fields' order changes.

Any idea on how I generate it, to be in the same order?
My goal is to trace schema changes in git.
conao3 commentedon Sep 30, 2023
just a note,
schema.introspect()is now missing andstr(schema)is just default str serializer.If you want to get result of introspect query,
And you want to get SDL of schema,
conao3 commentedon Oct 3, 2023
Sorry, this is graphene repo, not graphql-core. ignore me.