Skip to content

Commit

Permalink
Revert 1213 update mutation docs (#1214)
Browse files Browse the repository at this point in the history
* Revert "Update requirement for Query type in mutation docs (#1213)"

This reverts commit a9625da.

* Add test to check that Query type must be defined
  • Loading branch information
jkimbo committed Jun 29, 2020
1 parent 324df19 commit ecd11cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion docs/types/mutations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ So, we can finish our schema like this:
class MyMutations(graphene.ObjectType):
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
----------------------
Expand Down
2 changes: 1 addition & 1 deletion graphene/types/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class Schema:
questions about the types through introspection.
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.
mutation (Optional[Type[ObjectType]]): Root mutation *ObjectType*. Describes entry point for
fields to *create, update or delete* data in your API.
Expand Down
9 changes: 9 additions & 0 deletions graphene/types/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ def test_schema_str():
def test_schema_introspect():
schema = Schema(Query)
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."

0 comments on commit ecd11cc

Please sign in to comment.