在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):mirumee/ariadne开源软件地址(OpenSource Url):https://github.com/mirumee/ariadne开源编程语言(OpenSource Language):Python 100.0%开源软件介绍(OpenSource Introduction):AriadneAriadne is a Python library for implementing GraphQL servers.
Documentation is available here. Features
InstallationAriadne can be installed with pip: pip install ariadne QuickstartThe following example creates an API defining Start by installing uvicorn, an ASGI server we will use to serve the API: pip install uvicorn Then create an from ariadne import ObjectType, QueryType, gql, make_executable_schema
from ariadne.asgi import GraphQL
# Define types using Schema Definition Language (https://graphql.org/learn/schema/)
# Wrapping string in gql function provides validation and better error traceback
type_defs = gql("""
type Query {
people: [Person!]!
}
type Person {
firstName: String
lastName: String
age: Int
fullName: String
}
""")
# Map resolver functions to Query fields using QueryType
query = QueryType()
# Resolvers are simple python functions
@query.field("people")
def resolve_people(*_):
return [
{"firstName": "John", "lastName": "Doe", "age": 21},
{"firstName": "Bob", "lastName": "Boberson", "age": 24},
]
# Map resolver functions to custom type fields using ObjectType
person = ObjectType("Person")
@person.field("fullName")
def resolve_person_fullname(person, *_):
return "%s %s" % (person["firstName"], person["lastName"])
# Create executable GraphQL schema
schema = make_executable_schema(type_defs, query, person)
# Create an ASGI app using the schema, running in debug mode
app = GraphQL(schema, debug=True) Finally run the server: uvicorn example:app For more guides and examples, please see the documentation. ContributingWe are welcoming contributions to Ariadne! If you've found a bug or issue, feel free to use GitHub issues. If you have any questions or feedback, don't hesitate to catch us on GitHub discussions. For guidance and instructions, please see CONTRIBUTING.md. Website and the docs have their own GitHub repository: mirumee/ariadne-website Also make sure you follow @AriadneGraphQL on Twitter for latest updates, news and random musings! Crafted with |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论