How to use the tartiflette.types.input_object.GraphQLInputObjectType function in tartiflette

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 / 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 / unit / types / test_input_object.py View on Github external
def test_graphql_input_object_repr():
    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.__repr__() == "GraphQLInputObjectType(name='Name', "
        "fields=OrderedDict(["
        "('test', GraphQLArgument(name='arg', gql_type='Int', default_value=None, description=None, directives=None)), "
        "('another', GraphQLArgument(name='arg', gql_type='String', default_value=None, description=None, directives=None))"
        "]), description='description')"
github tartiflette / tartiflette / tests / unit / types / test_input_object.py View on Github external
## Different
    assert input_object != GraphQLInputObjectType(
        name="Name",
        fields=OrderedDict(
            [
                ("another", GraphQLArgument(name="arg", gql_type="String")),
                ("test", GraphQLArgument(name="arg", gql_type="Int")),
                # We reversed the order of arguments
            ]
        ),
    )
    assert input_object != GraphQLInputObjectType(
        name="Name", fields=OrderedDict()
    )
    assert input_object != GraphQLInputObjectType(
        name="OtherName",
        fields=OrderedDict(
            [
                ("another", GraphQLArgument(name="arg", gql_type="String")),
                ("test", GraphQLArgument(name="arg", gql_type="Int")),
                # We reversed the order of arguments
github tartiflette / tartiflette / tests / unit / types / test_input_object.py View on Github external
def test_graphql_input_object_eq():
    input_object = GraphQLInputObjectType(
        name="Name",
        fields=OrderedDict(
            [
                ("test", GraphQLArgument(name="arg", gql_type="Int")),
                ("another", GraphQLArgument(name="arg", gql_type="String")),
            ]
        ),
        description="description",
    )

    ## Same
    assert input_object == input_object
    assert input_object == GraphQLInputObjectType(
        name="Name",
        fields=OrderedDict(
            [
                ("test", GraphQLArgument(name="arg", gql_type="Int")),
                ("another", GraphQLArgument(name="arg", gql_type="String")),
            ]
        ),
        description="description",
    )
    # Currently we ignore the description in comparing
    assert input_object == GraphQLInputObjectType(
        name="Name",
        fields=OrderedDict(
            [
                ("test", GraphQLArgument(name="arg", gql_type="Int")),
                ("another", GraphQLArgument(name="arg", gql_type="String")),
github tartiflette / tartiflette / tests / unit / sdl / transformer / test_schema_transformer.py View on Github external
                            GraphQLInputObjectType,
                            name="UserProfileInput",
                            fields=OrderedDict(
                                [
                                    (
                                        "fullName",
                                        call_with_mocked_resolver_factory(
                                            GraphQLArgument,
                                            name="fullName",
                                            gql_type="String",
                                        ),
                                    )
                                ]
                            ),
                        )
                    ],
                )
github tartiflette / tartiflette / tartiflette / schema / schema.py View on Github external
def add_type_definition(self, type_definition: "GraphQLType") -> None:
        """
        Adds a GraphQLType to the defined type list.
        :param type_definition: GraphQLType to add
        :type type_definition: GraphQLType
        """
        if type_definition.name in self.type_definitions:
            raise RedefinedImplementation(
                "new GraphQL type definition `{}` "
                "overrides existing type definition `{}`.".format(
                    type_definition.name,
                    repr(self.type_definitions.get(type_definition.name)),
                )
            )
        self.type_definitions[type_definition.name] = type_definition
        if isinstance(type_definition, GraphQLInputObjectType):
            self._input_types.append(type_definition.name)
github tartiflette / tartiflette / tartiflette / sdl / transformers / schema_transformer.py View on Github external
description = child.value
            elif child.type == "IDENT":
                name = child.value
            elif child.type == "directives":
                directives = child.value
            elif child.type == "input_fields":
                fields = child.value
            elif child.type == "discard" or child.type == "INPUT":
                pass
            else:
                raise UnexpectedASTNode(
                    "Unexpected AST node `{}`, type `{}`".format(
                        child, child.__class__.__name__
                    )
                )
        return GraphQLInputObjectType(
            name=name,
            fields=fields,
            description=description,
            schema=self._schema,
            directives=directives,
        )
github tartiflette / tartiflette / tartiflette / types / input_object.py View on Github external
def __eq__(self, other: Any) -> bool:
        """
        Returns True if `other` instance is identical to `self`.
        :param other: object instance to compare to `self`
        :type other: Any
        :return: whether or not `other` is identical to `self`
        :rtype: bool
        """
        return self is other or (
            isinstance(other, GraphQLInputObjectType)
            and self.name == other.name
            and self.input_fields == other.input_fields
            and self.description == other.description
            and self.directives == other.directives
        )
github tartiflette / tartiflette / tartiflette / schema / schema.py View on Github external
type_definition.bake(self)

        for directive_definition in self._directive_definitions.values():
            directive_definition.bake(self)

        for type_definition in self.type_definitions.values():
            if isinstance(
                type_definition,
                (GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType),
            ):
                await type_definition.bake_fields(
                    self, custom_default_resolver
                )
            elif isinstance(type_definition, GraphQLEnumType):
                await type_definition.bake_enum_values(self)
            elif isinstance(type_definition, GraphQLInputObjectType):
                await type_definition.bake_input_fields(self)
github tartiflette / tartiflette / tartiflette / utils / arguments.py View on Github external
value.value
            if not input_coercer
            else input_coercer(value.value, info)
        )
    except AttributeError:
        pass

    if value is None:
        return None

    schema_type = argument_definition.schema.find_type(
        reduce_type(argument_definition.gql_type)
    )

    if (
        not isinstance(schema_type, GraphQLInputObjectType)
        or argument_definition.is_list_type
    ):
        return value

    if (
        not isinstance(argument_definition.gql_type, str)
        and argument_definition.is_list_type
    ):
        return await asyncio.gather(
            *[
                coerce_arguments(schema_type.arguments, x, ctx, info)
                for x in value
            ]
        )

    return await coerce_arguments(schema_type.arguments, value, ctx, info)