How to use tartiflette - 10 common examples

To help you get started, we’ve selected a few tartiflette examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tartiflette / tartiflette / tests / functional / regressions / test_issue270.py View on Github external
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",
github tartiflette / tartiflette / tests / unit / types / test_object.py View on Github external
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"
github tartiflette / tartiflette / tests / unit / types / test_interface.py View on Github external
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"
github tartiflette / tartiflette / tests / unit / types / test_field.py View on Github external
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"
github tartiflette / tartiflette / tests / unit / types / test_scalar.py View on Github external
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"
github tartiflette / tartiflette-asgi / tests / resolvers.py View on Github external
@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
github tartiflette / tartiflette / tests / unit / types / test_input_object.py View on Github external
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")),
        ]
github tartiflette / tartiflette / tests / functional / test_type_resolvers.py View on Github external
    @Resolver("Query.named", schema_name=random_schema_name)
    async def resolve_query_named(parent, args, ctx, info):
        return result
github tartiflette / tartiflette / tests / functional / regressions / test_issue127.py View on Github external
    @Resolver("Mutation.patchRecipe", schema_name="test_issue127")
    async def update_recipe(_, args, *__, **kwargs):
        return args["input"]
github tartiflette / tartiflette / tests / functional / regressions / test_oh_god.py View on Github external
    @Resolver("Dog.friends", schema_name="test_oh_god")
    async def resolve_pet_friends(*_, **__):
        return _PET_DATASET