Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert 1213 update mutation docs #1214

Merged
merged 2 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."