Merge branch 'master' into drop-python-3.6

This commit is contained in:
Erik Wrede 2023-07-19 09:08:00 +02:00 committed by GitHub
commit 2ef167eb7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 0 deletions

View File

@ -80,6 +80,10 @@ If we have a schema with Person type and one field on the root query.
from graphene import ObjectType, String, Field from graphene import ObjectType, String, Field
def get_human(name):
first_name, last_name = name.split()
return Person(first_name, last_name)
class Person(ObjectType): class Person(ObjectType):
full_name = String() full_name = String()

View File

@ -0,0 +1,41 @@
# https://github.com/graphql-python/graphene/issues/1293
import datetime
import graphene
from graphql.utilities import print_schema
class Filters(graphene.InputObjectType):
datetime_after = graphene.DateTime(
required=False,
default_value=datetime.datetime.utcfromtimestamp(1434549820776 / 1000),
)
datetime_before = graphene.DateTime(
required=False,
default_value=datetime.datetime.utcfromtimestamp(1444549820776 / 1000),
)
class SetDatetime(graphene.Mutation):
class Arguments:
filters = Filters(required=True)
ok = graphene.Boolean()
def mutate(root, info, filters):
return SetDatetime(ok=True)
class Query(graphene.ObjectType):
goodbye = graphene.String()
class Mutations(graphene.ObjectType):
set_datetime = SetDatetime.Field()
def test_schema_printable_with_default_datetime_value():
schema = graphene.Schema(query=Query, mutation=Mutations)
schema_str = print_schema(schema.graphql_schema)
assert schema_str, "empty schema printed"