Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def ttftt_engine():
@Resolver("Mutation.mutateFloat", schema_name="issue270")
async def resolver_test(pr, args, ctx, info, **kwargs):
return {"bingo": f"{args['aFloat']}"}
return await create_engine(
sdl="""
type Payload {
clientMutationId: String,
bingo: String
}
type Mutation {
mutateFloat(aFloat: Float): Payload
}
type Query {
bob: String
}
""",
schema_name="issue270",
def test_graphql_object_init(mocked_resolver_factory):
obj = GraphQLObjectType(
name="Name",
fields=OrderedDict(
[
("test", GraphQLField(name="arg", gql_type="Int")),
("another", GraphQLField(name="arg", gql_type="String")),
]
),
interfaces=["First", "Second"],
description="description",
)
assert obj.name == "Name"
assert obj.find_field("test") == GraphQLField(name="arg", gql_type="Int")
assert obj.find_field("another") == GraphQLField(
name="arg", gql_type="String"
)
assert obj.interfaces_names == ["First", "Second"]
assert obj.description == "description"
def test_graphql_interface_init():
interface = GraphQLInterfaceType(name="Name",
fields=OrderedDict([
("test", GraphQLField(name="arg", gql_type="Int")),
("another", GraphQLField(name="arg", gql_type="String")),
]),
description="description")
assert interface.name == "Name"
assert interface.fields == OrderedDict([
("test", GraphQLField(name="arg", gql_type="Int")),
("another", GraphQLField(name="arg", gql_type="String")),
])
assert interface.description == "description"
def test_graphql_field_init():
field = GraphQLField(
name="Name",
gql_type="Test",
arguments=OrderedDict([("test", 42), ("another", 24)]),
description="description",
)
assert field.name == "Name"
assert field.gql_type == "Test"
assert field.arguments == OrderedDict([("test", 42), ("another", 24)])
assert field.resolver._directivated_func is default_resolver
assert field.description == "description"
def test_graphql_scalar_init():
scalar = GraphQLScalarType(name="Name", description="description")
assert scalar.name == "Name"
assert scalar.coerce_output is None
assert scalar.coerce_input is None
assert scalar.description == "description"
@Subscription("Subscription.dogAdded")
async def on_dog_added(
parent: typing.Any, args: dict, ctx: dict, info: dict
) -> typing.AsyncIterator[dict]:
pubsub: PubSub = ctx["pubsub"]
queue: Queue = Queue()
@pubsub.on("dog_added")
def on_dog(dog: Dog) -> None:
queue.put(dog)
while True:
try:
dog = queue.get_nowait()
except Empty:
await asyncio.sleep(0.01)
continue
def test_graphql_input_object_init():
input_object = GraphQLInputObjectType(
name="Name",
fields=OrderedDict(
[
("test", GraphQLArgument(name="arg", gql_type="Int")),
("another", GraphQLArgument(name="arg", gql_type="String")),
]
),
description="description",
)
assert input_object.name == "Name"
assert input_object._fields == OrderedDict(
[
("test", GraphQLArgument(name="arg", gql_type="Int")),
("another", GraphQLArgument(name="arg", gql_type="String")),
]
@Resolver("Query.named", schema_name=random_schema_name)
async def resolve_query_named(parent, args, ctx, info):
return result
@Resolver("Mutation.patchRecipe", schema_name="test_issue127")
async def update_recipe(_, args, *__, **kwargs):
return args["input"]
@Resolver("Dog.friends", schema_name="test_oh_god")
async def resolve_pet_friends(*_, **__):
return _PET_DATASET