Package: turms
turmsGoalTurms is agraphql-codegeninspired code generator for python that generates typed and serializable python code from your graphql schema and documents. Just define your query in standard graphql syntax and let turms create fully typed queries/mutation and subscriptions, that you can use in your favourite IDE.Turms allows you to easily generate both server-side and client-side code for your GraphQL API.Schema (Server) Generation:Can generate the following types from your graphql SDL schema:EnumsInputsObjectsScalarsDirectivesSepcific generation supported for:StrawberryGrapheneDocuments (Client) GenerationCan generate the following pydantic models from your graphql documents:EnumsInputsScalarsFragmentsOperationsFeaturesFully typed, fully documented code generationSchema and Document based code generationCompatible with popular graphql libraries (strawberry, gql, rath, etc.)Support for custom scalars, custom directives, ...Powerful plugin system (e.g. custom Linting, custom formatting, etc.)Operation functions like query, mutation, subscription (e.g.data= get_capsules())Compliant with graphl-configCode migration support (trying to merge updates into existing code)Installationpipinstallturmsturms is a pure development library and will not introduce any dependency on itself into your
code, so we recommend installing turms as a development dependency.poetryadd-DturmsAs of now turms only supports python 3.9 and higher (as we rely on ast unparsing)ConfigurationTurms relies on and complies withgraphql-configand searches your current working dir for the graphql-config file.Document based generationBased on pydantic modelsprojects:default:schema:http://api.spacex.land/graphql/documents:graphql/**.graphqlextensions:turms:# path for configuration for turmsout_dir:examples/apiplugins:# path for plugin configuration-type:turms.plugins.enums.EnumsPlugin-type:turms.plugins.inputs.InputsPlugin-type:turms.plugins.fragments.FragmentsPlugin-type:turms.plugins.operation.OperationsPlugin-type:turms.plugins.funcs.FuncsPluginprocessors:-type:turms.processor.black.BlackProcessor-type:turms.processor.isort.IsortProcessorscalar_definitions:uuid:strtimestamptz:strDate:strSchema based generationBased on strawberry modelsprojects:default:schema:beasts.graphqlextensions:turms:skip_forwards:trueout_dir:apistylers:-type:turms.stylers.capitalize.CapitalizeStyler-type:turms.stylers.snake_case.SnakeCaseStylerplugins:-type:turms.plugins.strawberry.StrawberryPlugin# generates a strawberry schemaprocessors:-type:turms.processors.disclaimer.DisclaimerProcessor-type:turms.processors.black.BlackProcessor-type:turms.processors.isort.IsortProcessor-type:turms.processors.merge.MergeProcessor# merges the formated schema with already defined functionsscalar_definitions:uuid:str_Any:typing.AnyUsageOnce you have configured turms you can generate your code by runningturmsgenWhy TurmsIn Etruscan religion, Turms (usually written as 𐌕𐌖𐌓𐌌𐌑 Turmś in the Etruscan alphabet) was the equivalent of Roman Mercury and Greek Hermes, both gods of trade and themessengergod between people and gods.Transport LayerTurms doesnotcome with a default transport layer but if you are searching for an Apollo-like GraphQL Client you can check outrath, that works especially well with turms.ExamplesThis github repository also contains some examples on how to use turms with popular libraries in the graphql ecosystem.