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:
import json
schema = graphene.Schema(....)
introspection_dict = schema.introspect()
# Print the schema in the console
print json.dump(introspection_dict)
# Or save the schema into some file
open('schema.json', ‘w’) as fp:
json.dump(introspection_dict, fp)
Thanks @jhgg for showing me the way :wink:
No problem!
This should be automatically exposed by Graphene as a query that returns the file.
If you want to get schema in GraphQL SDL format:
>>> from your_project.schema_definition import schema
>>> print(schema)
schema {
query: Query
mutation: Mutation
}
type CreateUser {
user: User
message: String
success: Boolean
}
# and so on ...
Most helpful comment
@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: