Package: py-gql
py-gqlpy-gql is a pure pythonGraphQLimplementation aimed at creating GraphQL servers and providing common tooling.It supports:Parsing the GraphQL query language and schema definition language.Building a GraphQL type schema programmatically and from Schema Definition files (including support for schema directives).Validating and Executing a GraphQL request against a type schema.Quick linksSource Code & Issue TrackerPyPI projectRead The DocsChangelogInstallationpipinstallpy-gqlFor more details seeinstall.rst.Usage & Examplesfrompy_gqlimportbuild_schema,graphql_blockingschema=build_schema("""type Query {hello(value: String = "world"): String!}""")@schema.resolver("Query.hello")defresolve_hello(*_,value):return"Hello{}!".format(value)result=graphql_blocking(schema,'{ hello(value: "World") }')assertresult.response()=={"data":{"hello":"Hello World!"}}For more usage examples, you can refer to theUser Guideand some more involved examples available in theexamplesfolder.Thetestsshould also provide some contrived examples.Goals & StatusThis project was initially born as an experiment / learning project following some frustration withgraphql-coreandGrapheneI encountered at work.The main goals were originally to:Get a deeper understanding of GraphQLProvide an alternative tographql-corewhich:tracks the latest version of the spec (whichgraphql-coredidn't at the time)does so without being a port of the JS code which leads to some weird edge case when we tried to extend the librarykeeps support for Python 2(subjective) attempts to be a bit more usable for our use cases, the ideal result would sit somewhere in betweenGrapheneandgraphql-coremakes it easier for us to build / include some extra tooling such as custom tracing, custom validation and SDL based tools as well as builder infrastructure to support easily implementing graphql layers over existing data layers (such as ORM)Not all these points are satisfied yet, and some have been changed over time, but py-gql should be ready for general use. It is however still in a fairly experimental phase and to reflect that versions are still in the0.x.y.The API is still subject to change as different part of the codebase are iterated on and are getting more use against production codebases.Development setupMake sure you are using Python 3.6+ (you can run the tests under 3.5 but `other development tasks such as black are not guaranteed to work).Clone this repo and create a virtualenv before installing the development dependencies:gitclonegit@github.com:lirsacc/py-gql.git
python-mvenv$WORKON_HOME/py-gql--copies
pipinstall-U-rrequirements-dev.txt
pipinstall-e.Development tasks are available throughinvoke. Checktasks.pyor useinv -lto list all available tasks andinv --help {TASK}to get help on a specific task. Most of the tools used should be usable directly, but the tasks provide some common aliases and targets.As a shortcut,inv checkwill run all checks that are normally run on CI (lint, typecheck and tests).CI is done onGithub Actions.BranchesThe last tag should correspond to the latest release versionmastercontains unreleased changes that are planned to be releaseddevis used for experimenting and hard changes such as rebase and force pushed should be expected. For now this is the branch I used in side projects and where most of the iteration happens.