mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-22 01:26:49 +03:00
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:
parent
324df19d3d
commit
ecd11ccc1e
|
@ -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
|
||||
----------------------
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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."
|
||||
|
|
Loading…
Reference in New Issue
Block a user