Revert 1213 update mutation docs (#1214)

* Revert "Update requirement for Query type in mutation docs (#1213)"

This reverts commit a9625dac0e.

* Add test to check that Query type must be defined
This commit is contained in:
Jonathan Kim 2020-06-29 15:53:53 +01:00 committed by GitHub
parent 324df19d3d
commit ecd11ccc1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -48,7 +48,11 @@ So, we can finish our schema like this:
class MyMutations(graphene.ObjectType): class MyMutations(graphene.ObjectType):
create_person = CreatePerson.Field() create_person = CreatePerson.Field()
schema = graphene.Schema(mutation=MyMutations) # We must define a query for our schema
class Query(graphene.ObjectType):
person = graphene.Field(Person)
schema = graphene.Schema(query=Query, mutation=MyMutations)
Executing the Mutation Executing the Mutation
---------------------- ----------------------

View File

@ -381,7 +381,7 @@ class Schema:
questions about the types through introspection. questions about the types through introspection.
Args: Args:
query (Optional[Type[ObjectType]]): Root query *ObjectType*. Describes entry point for fields to *read* query (Type[ObjectType]): Root query *ObjectType*. Describes entry point for fields to *read*
data in your Schema. data in your Schema.
mutation (Optional[Type[ObjectType]]): Root mutation *ObjectType*. Describes entry point for mutation (Optional[Type[ObjectType]]): Root mutation *ObjectType*. Describes entry point for
fields to *create, update or delete* data in your API. fields to *create, update or delete* data in your API.

View File

@ -59,3 +59,12 @@ def test_schema_str():
def test_schema_introspect(): def test_schema_introspect():
schema = Schema(Query) schema = Schema(Query)
assert "__schema" in schema.introspect() assert "__schema" in schema.introspect()
def test_schema_requires_query_type():
schema = Schema()
result = schema.execute("query {}")
assert len(result.errors) == 1
error = result.errors[0]
assert error.message == "Query root type must be provided."