How to use the tartiflette.types.list.GraphQLList 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 / helpers / test_reduce_type.py View on Github external
            GraphQLList(gql_type=GraphQLNonNull(gql_type="MyObject")),
            "MyObject",
        ),
        (
            GraphQLNonNull(
                gql_type=GraphQLList(
                    gql_type=GraphQLNonNull(gql_type="LeafType")
                )
            ),
            "LeafType",
        ),
    ],
)
def test_reduce_type(gql_type, expected):
    reduced_gql_type = reduce_type(gql_type)
    assert reduced_gql_type == expected
github tartiflette / tartiflette / tests / unit / resolver / test_factory.py View on Github external
        (GraphQLList(gql_type="aType"), True),
        (GraphQLNonNull(gql_type="aType"), False),
        (GraphQLNonNull(gql_type=GraphQLList(gql_type="aType")), True),
        (None, False),
    ],
)
def test_resolver_factory__shall_return_a_list(field_type, expected):
    from tartiflette.resolver.factoryyy import _shall_return_a_list

    assert _shall_return_a_list(field_type) == expected
github tartiflette / tartiflette / tests / unit / types / test_list.py View on Github external
def test_graphql_list_eq():
    lst = GraphQLList(gql_type="Name", description="description")

    ## Same
    assert lst == lst
    assert lst == GraphQLList(gql_type="Name", description="description")
    # Currently we ignore the description in comparing
    assert lst == GraphQLList(gql_type="Name")

    ## Different
    assert lst != GraphQLList(gql_type="OtherName")
github tartiflette / tartiflette / tests / unit / utils / test_coercer.py View on Github external
def test_utils_coercers__get_type_coercers():
    from tartiflette.utils.coercer import _get_type_coercers
    from tartiflette.types.list import GraphQLList
    from tartiflette.types.non_null import GraphQLNonNull
    from tartiflette.utils.coercer import _list_coercer, _not_null_coercer

    assert _get_type_coercers("aType") == []
    assert _get_type_coercers(None) == []
    assert _get_type_coercers(GraphQLList(gql_type="aType")) == [_list_coercer]
    assert _get_type_coercers(GraphQLNonNull(gql_type="aType")) == [
        _not_null_coercer
    ]
    assert _get_type_coercers(
        GraphQLList(gql_type=GraphQLNonNull(gql_type="aType"))
    ) == [_list_coercer, _not_null_coercer]
    assert _get_type_coercers(
        GraphQLNonNull(
            gql_type=GraphQLList(gql_type=GraphQLNonNull(gql_type="aType"))
        )
    ) == [_not_null_coercer, _list_coercer, _not_null_coercer]
github tartiflette / tartiflette / tests / unit / types / test_list.py View on Github external
def test_graphql_list_repr():
    lst = GraphQLList(gql_type="Name", description="description")

    assert (
        lst.__repr__() == "GraphQLList(gql_type='Name', "
        "description='description')"
    )
    assert lst == eval(repr(lst))
github tartiflette / tartiflette / tests / unit / types / test_list.py View on Github external
def test_graphql_list_eq():
    lst = GraphQLList(gql_type="Name", description="description")

    ## Same
    assert lst == lst
    assert lst == GraphQLList(gql_type="Name", description="description")
    # Currently we ignore the description in comparing
    assert lst == GraphQLList(gql_type="Name")

    ## Different
    assert lst != GraphQLList(gql_type="OtherName")
github tartiflette / tartiflette / tests / unit / resolver / test_factory__resolver_executor.py View on Github external
_resolver_executor_mock._schema_field = GraphQLField("A", gql_type="F")

    assert not _resolver_executor_mock.contains_not_null
    _resolver_executor_mock._schema_field = GraphQLField(
        "A", gql_type=GraphQLNonNull(gql_type="F")
    )
    assert _resolver_executor_mock.contains_not_null

    _resolver_executor_mock._schema_field = GraphQLField(
        "A", gql_type=GraphQLList(gql_type=GraphQLNonNull(gql_type="F"))
    )
    assert _resolver_executor_mock.contains_not_null

    _resolver_executor_mock._schema_field = GraphQLField(
        "A", gql_type=GraphQLList(gql_type="F")
    )
    assert not _resolver_executor_mock.contains_not_null
github tartiflette / tartiflette / tartiflette / language / validators / query / values_of_correct_type.py View on Github external
)
                return errors

            errors = self._validate(
                r_argument_schema_type,
                c_argument_schema_type.gql_type,
                arg,
                path,
                errors,
                schema,
                value_node=value_node,
                input_field=input_field,
            )
            return errors

        if isinstance(c_argument_schema_type, GraphQLList):
            if isinstance(value_node, NullValueNode):
                return errors

            arg_values = (
                [value_node]
                if not isinstance(value_node, ListValueNode)
                else value_node.values
            )

            for arg_value in arg_values:
                if isinstance(arg_value, VariableNode):
                    continue  # Handled by another validator

                errors = self._validate(
                    r_argument_schema_type,
                    c_argument_schema_type.gql_type,
github tartiflette / tartiflette / tartiflette / schema / transformer.py View on Github external
type_node: "TypeNode", schema: "GraphQLSchema"
) -> Union["GraphQLList", "GraphQLNonNull", str]:
    """
    Computes an AST type node into its GraphQL representation.
    :param type_node: AST type node to treat
    :param schema: the GraphQLSchema instance linked to the engine
    :type type_node: TypeNode
    :type schema: GraphQLSchema
    :return: the GraphQL representation of the type node
    :rtype: Union[GraphQLList, GraphQLNonNull, str]
    """
    inner_type_node = type_node
    type_wrappers = []
    while isinstance(inner_type_node, (NonNullTypeNode, ListTypeNode)):
        if isinstance(inner_type_node, ListTypeNode):
            type_wrappers.append(partial(GraphQLList, schema=schema))
        elif isinstance(inner_type_node, NonNullTypeNode):
            type_wrappers.append(
                partial(partial(GraphQLNonNull, schema=schema))
            )
        inner_type_node = inner_type_node.type

    graphql_type = parse_named_type(inner_type_node, schema)
    for type_wrapper in reversed(type_wrappers):
        graphql_type = type_wrapper(gql_type=graphql_type)
    return graphql_type
github tartiflette / tartiflette / tartiflette / sdl / transformers / schema_transformer.py View on Github external
def list_type(self, tree: Tree) -> SchemaNode:
        return SchemaNode(
            "list_type",
            GraphQLList(gql_type=tree.children[0].value, schema=self._schema),
        )