コード例 #1
0
ファイル: test_definition.py プロジェクト: Austin-cp/cp-0.1.1
def test_includes_nested_input_objects_in_the_map():
    NestedInputObject = GraphQLInputObjectType(
        name="NestedInputObject",
        fields={"value": GraphQLInputObjectField(GraphQLString)},
    )

    SomeInputObject = GraphQLInputObjectType(
        name="SomeInputObject",
        fields={"nested": GraphQLInputObjectField(NestedInputObject)},
    )

    SomeMutation = GraphQLObjectType(
        name="SomeMutation",
        fields={
            "mutateSomething":
            GraphQLField(type=BlogArticle,
                         args={"input": GraphQLArgument(SomeInputObject)})
        },
    )
    SomeSubscription = GraphQLObjectType(
        name="SomeSubscription",
        fields={
            "subscribeToSomething":
            GraphQLField(type=BlogArticle,
                         args={"input": GraphQLArgument(SomeInputObject)})
        },
    )

    schema = GraphQLSchema(query=BlogQuery,
                           mutation=SomeMutation,
                           subscription=SomeSubscription)

    assert schema.get_type_map()["NestedInputObject"] is NestedInputObject
コード例 #2
0
def test_includes_nested_input_objects_in_the_map():
    NestedInputObject = GraphQLInputObjectType(
        name='NestedInputObject',
        fields={'value': GraphQLInputObjectField(GraphQLString)})

    SomeInputObject = GraphQLInputObjectType(
        name='SomeInputObject',
        fields={'nested': GraphQLInputObjectField(NestedInputObject)})

    SomeMutation = GraphQLObjectType(
        name='SomeMutation',
        fields={
            'mutateSomething':
            GraphQLField(type=BlogArticle,
                         args={'input': GraphQLArgument(SomeInputObject)})
        })
    SomeSubscription = GraphQLObjectType(
        name='SomeSubscription',
        fields={
            'subscribeToSomething':
            GraphQLField(type=BlogArticle,
                         args={'input': GraphQLArgument(SomeInputObject)})
        })

    schema = GraphQLSchema(query=BlogQuery,
                           mutation=SomeMutation,
                           subscription=SomeSubscription)

    assert schema.get_type_map()['NestedInputObject'] is NestedInputObject
コード例 #3
0
def test_includes_interfaces_thunk_subtypes_in_the_type_map():
    SomeInterface = GraphQLInterfaceType(
        name='SomeInterface',
        fields={
            'f': GraphQLField(GraphQLInt)
        }
    )

    SomeSubtype = GraphQLObjectType(
        name='SomeSubtype',
        fields={
            'f': GraphQLField(GraphQLInt)
        },
        interfaces=lambda: [SomeInterface],
        is_type_of=lambda: True
    )

    schema = GraphQLSchema(query=GraphQLObjectType(
        name='Query',
        fields={
            'iface': GraphQLField(SomeInterface)
        }
    ), types=[SomeSubtype])

    assert schema.get_type_map()['SomeSubtype'] is SomeSubtype
コード例 #4
0
def test_includes_interfaces_thunk_subtypes_in_the_type_map():
    SomeInterface = GraphQLInterfaceType(
        name='SomeInterface',
        fields={
            'f': GraphQLField(GraphQLInt)
        }
    )

    SomeSubtype = GraphQLObjectType(
        name='SomeSubtype',
        fields={
            'f': GraphQLField(GraphQLInt)
        },
        interfaces=lambda: [SomeInterface],
        is_type_of=lambda: True
    )

    schema = GraphQLSchema(query=GraphQLObjectType(
        name='Query',
        fields={
            'iface': GraphQLField(SomeInterface)
        }
    ), types=[SomeSubtype])

    assert schema.get_type_map()['SomeSubtype'] is SomeSubtype
コード例 #5
0
ファイル: test_definition.py プロジェクト: Austin-cp/cp-0.1.1
def test_includes_interface_possible_types_in_the_type_map():
    SomeInterface = GraphQLInterfaceType(
        "SomeInterface", fields={"f": GraphQLField(GraphQLInt)})
    SomeSubtype = GraphQLObjectType(
        name="SomeSubtype",
        fields={"f": GraphQLField(GraphQLInt)},
        interfaces=[SomeInterface],
        is_type_of=lambda: None,
    )
    schema = GraphQLSchema(
        query=GraphQLObjectType(name="Query",
                                fields={"iface": GraphQLField(SomeInterface)}),
        types=[SomeSubtype],
    )
    assert schema.get_type_map()["SomeSubtype"] == SomeSubtype
コード例 #6
0
def test_includes_nested_input_objects_in_the_map():
    NestedInputObject = GraphQLInputObjectType(
        name='NestedInputObject',
        fields={'value': GraphQLInputObjectField(GraphQLString)}
    )

    SomeInputObject = GraphQLInputObjectType(
        name='SomeInputObject',
        fields={'nested': GraphQLInputObjectField(NestedInputObject)}
    )

    SomeMutation = GraphQLObjectType(
        name='SomeMutation',
        fields={
            'mutateSomething': GraphQLField(
                type=BlogArticle,
                args={
                    'input': GraphQLArgument(SomeInputObject)
                }
            )
        }
    )
    SomeSubscription = GraphQLObjectType(
        name='SomeSubscription',
        fields={
            'subscribeToSomething': GraphQLField(
                type=BlogArticle,
                args={
                    'input': GraphQLArgument(SomeInputObject)
                }
            )
        }
    )

    schema = GraphQLSchema(
        query=BlogQuery,
        mutation=SomeMutation,
        subscription=SomeSubscription
    )

    assert schema.get_type_map()['NestedInputObject'] is NestedInputObject