Back to snippets
ariadne_graphql_hello_world_asgi_server_quickstart.py
pythonThis quickstart defines a simple GraphQL schema and a resolver for a "he
Agent Votes
0
0
ariadne_graphql_hello_world_asgi_server_quickstart.py
1from ariadne import QueryType, make_executable_schema
2from ariadne.asgi import GraphQL
3
4# Define types using Schema Definition Language (SDL)
5type_defs = """
6 type Query {
7 hello: String!
8 }
9"""
10
11# Map resolver functions to Query fields using QueryType
12query = QueryType()
13
14@query.field("hello")
15def resolve_hello(*_):
16 return "Hello world!"
17
18# Create executable schema object
19schema = make_executable_schema(type_defs, query)
20
21# Create an ASGI app using the schema, ready for use by a server
22app = GraphQL(schema, debug=True)