How to create a sample graphql code in Python?

  Kiến thức lập trình

I’m trying to create a small sample GraphQL code in python, but it is failing.

>>> from graphql import graphql_sync, build_schema
>>> schema = build_schema('''  type Query { hello: String } ''')
>>> def resolve_hello(parent, info):
...     return 'Hello World!'
...
>>> root_value = {'hello': resolve_hello}
>>> query = '{hello}'
>>> result = graphql_sync(schema, query, root_value=root_value)
>>> result
ExecutionResult(data={'hello': None}, errors=[GraphQLError("resolve_hello() missing 1 required positional argument: 'info'", locations=[SourceLocation(line=1, column=2)], path=['hello'])])

New contributor

Ganapathy Chidambaram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT