Is there a lib/tool for Python to automatically parse a graphqls file? If not, what is a good way to parse the file?
I have a Python project that is part of a larger Java project that contains a .graphqls file with the enum, input, and type definitions.
For example, the file has:
enum Version {
A
B
}
input ProjInput {
name: String!
term: String
version: Version
}
type ProjType {
name: String
term: String
version: Version
}
The file also contains the queries and mutations:
type Query {
queryProj(projName: String!): ProjType
}
type Mutation {
addProj(projInput: ProjInput): ProjType
}
I looked around but I can't find a tool to parse this data into a dict (or some other type) in Python. It would be nice to just do something like parsing json with json.loads().
Does such a lib/tool exist? And if not, how can I parse this file myself?
I can open and read the file, I am just not sure if just reading it line-by-line is a good method, or if I can automatically read enum types, for example.
You can parse graphql schema file, inspect it, and print the schema details as a dictionary in JSON-like format using 'graphql-core-next' library . However it doesn't handle the queries and mutations. You need to investigate further to cover that part using more advanced library.
assuming that u have installed the library using
You can use below method to try it out