Package: ariadne
AriadneAriadne is a Python library for implementingGraphQLservers.Schema-first:Ariadne enables Python developers to use schema-first approach to the API implementation. This is the leading approach used by the GraphQL community and supported by dozens of frontend and backend developer tools, examples, and learning resources. Ariadne makes all of this immediately available to you and other members of your team.Simple:Ariadne offers small, consistent and easy to memorize API that lets developers focus on business problems, not the boilerplate.Open:Ariadne was designed to be modular and open for customization. If you are missing or unhappy with something, extend or easily swap with your own.Documentation is availablehere.FeaturesSimple, quick to learn and easy to memorize API.Compatibility with GraphQL.js version 15.5.1.Queries, mutations and input types.Asynchronous resolvers and query execution.Subscriptions.Custom scalars, enums and schema directives.Unions and interfaces.File uploads.Defining schema using SDL strings.Loading schema from.graphql,.gql, and.graphqlsfiles.WSGI middleware for implementing GraphQL in existing sites.Apollo Tracing andOpenTracingextensions for API monitoring.Opt-in automatic resolvers mapping betweencamelCaseandsnake_case, and a@convert_kwargs_to_snake_casefunction decorator for convertingcamelCasekwargs tosnake_case.Built-in simple synchronous dev server for quick GraphQL experimentation and GraphQL Playground.Support forApollo GraphQL extension for Visual Studio Code.GraphQL syntax validation viagql()helper function. Also provides colorization if Apollo GraphQL extension is installed.No global state or object registry, support for multiple GraphQL APIs in same codebase with explicit type reuse.Support forApollo Federation.InstallationAriadne can be installed with pip:pip install ariadneAriadne requires Python 3.7 or higher.QuickstartThe following example creates an API definingPersontype and single query fieldpeoplereturning a list of two persons. It also starts a local dev server withGraphQL Playgroundavailable on thehttp://127.0.0.1:8000address.Start by installinguvicorn, an ASGI server we will use to serve the API:pip install uvicornThen create anexample.pyfile for your example application:fromariadneimportObjectType,QueryType,gql,make_executable_schemafromariadne.asgiimportGraphQL# Define types using Schema Definition Language (https://graphql.org/learn/schema/)# Wrapping string in gql function provides validation and better error tracebacktype_defs=gql("""type Query {people: [Person!]!}type Person {firstName: StringlastName: Stringage: IntfullName: String}""")# Map resolver functions to Query fields using QueryTypequery=QueryType()# Resolvers are simple python functions@query.field("people")defresolve_people(*_):return[{"firstName":"John","lastName":"Doe","age":21},{"firstName":"Bob","lastName":"Boberson","age":24},]# Map resolver functions to custom type fields using ObjectTypeperson=ObjectType("Person")@person.field("fullName")defresolve_person_fullname(person,*_):return"%s%s"%(person["firstName"],person["lastName"])# Create executable GraphQL schemaschema=make_executable_schema(type_defs,query,person)# Create an ASGI app using the schema, running in debug modeapp=GraphQL(schema,debug=True)Finally run the server:uvicorn example:appFor more guides and examples, please see thedocumentation.ContributingWe are welcoming contributions to Ariadne! If you've found a bug or issue, feel free to useGitHub issues. If you have any questions or feedback, don't hesitate to catch us onGitHub discussions.For guidance and instructions, please seeCONTRIBUTING.md.Website and the docs have their own GitHub repository:mirumee/ariadne-websiteAlso make sure you follow@AriadneGraphQLon Twitter for latest updates, news and random musings!Crafted with ❤️ byMirumee Softwarehello@mirumee.com