当前位置: 首页>>代码示例>>Python>>正文


Python graphene.String方法代码示例

本文整理汇总了Python中graphene.String方法的典型用法代码示例。如果您正苦于以下问题:Python graphene.String方法的具体用法?Python graphene.String怎么用?Python graphene.String使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在graphene的用法示例。


在下文中一共展示了graphene.String方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_service_query

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def get_service_query(schema):
    sdl_str = get_sdl(schema, custom_entities)

    class _Service(ObjectType):
        sdl = String()

        def resolve_sdl(parent, _):
            return sdl_str

    class ServiceQuery(ObjectType):
        _service = Field(_Service, name="_service")

        def resolve__service(parent, info):
            return _Service()

    return ServiceQuery 
开发者ID:preply,项目名称:graphene-federation,代码行数:18,代码来源:service.py

示例2: to_graphql_fields

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def to_graphql_fields(self):
        return {
            self.limit_query_param: Int(
                default_value=self.default_limit,
                description="Number of results to return per page. Default "
                "'default_limit': {}, and 'max_limit': {}".format(
                    self.default_limit, self.max_limit
                ),
            ),
            self.offset_query_param: Int(
                description="The initial index from which to return the results. Default: 0"
            ),
            self.ordering_param: String(
                description="A string or comma delimited string values that indicate the "
                "default ordering when obtaining lists of objects."
            ),
        } 
开发者ID:eamigo86,项目名称:graphene-django-extras,代码行数:19,代码来源:pagination.py

示例3: test_should_composite_convert

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def test_should_composite_convert():
    registry = Registry()

    class CompositeClass:
        def __init__(self, col1, col2):
            self.col1 = col1
            self.col2 = col2

    @convert_sqlalchemy_composite.register(CompositeClass, registry)
    def convert_composite_class(composite, registry):
        return graphene.String(description=composite.doc)

    field = convert_sqlalchemy_composite(
        composite(CompositeClass, (Column(types.Unicode(50)), Column(types.Unicode(50))), doc="Custom Help Text"),
        registry,
        mock_resolver,
    )
    assert isinstance(field, graphene.String) 
开发者ID:graphql-python,项目名称:graphene-sqlalchemy,代码行数:20,代码来源:test_converter.py

示例4: test_does_not_auto_camel_case

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def test_does_not_auto_camel_case(self):

        # a query to test with a snake case field
        class TestQuery(ObjectType):
            test_field = String()

            def resolve_test_field(self, args, info):
                return 'hello'

        # assign the query to the schema
        self.schema.query = TestQuery

        # the query to test
        test_query = "query {test_field}"

        # execute the query
        resolved_query = self.schema.execute(test_query)

        assert 'test_field' in resolved_query.data, (
            "Schema did not have snake_case field."
        )

        assert resolved_query.data['test_field'] == 'hello', (
            "Snake_case field did not have the right value"
        ) 
开发者ID:AlecAivazis,项目名称:graphql-over-kafka,代码行数:27,代码来源:test_schema.py

示例5: test_should_postgres_array_multiple_convert_list

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def test_should_postgres_array_multiple_convert_list():
    field = assert_conversion(
        ArrayField, graphene.List, ArrayField(models.CharField(max_length=100))
    )
    assert isinstance(field.type, graphene.NonNull)
    assert isinstance(field.type.of_type, graphene.List)
    assert isinstance(field.type.of_type.of_type, graphene.List)
    assert isinstance(field.type.of_type.of_type.of_type, graphene.NonNull)
    assert field.type.of_type.of_type.of_type.of_type == graphene.String

    field = assert_conversion(
        ArrayField,
        graphene.List,
        ArrayField(models.CharField(max_length=100, null=True)),
    )
    assert isinstance(field.type, graphene.NonNull)
    assert isinstance(field.type.of_type, graphene.List)
    assert isinstance(field.type.of_type.of_type, graphene.List)
    assert field.type.of_type.of_type.of_type == graphene.String 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:21,代码来源:test_converter.py

示例6: convert_ndb_string_property

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def convert_ndb_string_property(ndb_prop, registry=None):
    return convert_ndb_scalar_property(String, ndb_prop) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:4,代码来源:converter.py

示例7: convert_ndb_key_propety

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def convert_ndb_key_propety(ndb_key_prop, registry=None):
    """
    Two conventions for handling KeyProperties:
    #1.
        Given:
            store_key = ndb.KeyProperty(...)

        Result is 2 fields:
            store_id  = graphene.String() -> resolves to store_key.urlsafe()
            store     = NdbKeyField()     -> resolves to entity

    #2.
        Given:
            store = ndb.KeyProperty(...)

        Result is 2 fields:
            store_id = graphene.String() -> resolves to store_key.urlsafe()
            store     = NdbKeyField()    -> resolves to entity

    """
    is_repeated = ndb_key_prop._repeated
    name = ndb_key_prop._code_name

    if name.endswith('_key') or name.endswith('_keys'):
        # Case #1 - name is of form 'store_key' or 'store_keys'
        string_prop_name = rreplace(name, '_key', '_id', 1)
        resolved_prop_name = name[:-4] if name.endswith('_key') else p.plural(name[:-5])
    else:
        # Case #2 - name is of form 'store'
        singular_name = p.singular_noun(name) if p.singular_noun(name) else name
        string_prop_name = singular_name + '_ids' if is_repeated else singular_name + '_id'
        resolved_prop_name = name

    return [
        ConversionResult(name=string_prop_name, field=DynamicNdbKeyStringField(ndb_key_prop, registry=registry)),
        ConversionResult(name=resolved_prop_name, field=DynamicNdbKeyReferenceField(ndb_key_prop, registry=registry))
    ] 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:39,代码来源:converter.py

示例8: convert_computed_property

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def convert_computed_property(ndb_computed_prop, registry=None):
    return convert_ndb_scalar_property(String, ndb_computed_prop) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:4,代码来源:converter.py

示例9: testGET_support_json_variables

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def testGET_support_json_variables(self):
        response = self.app.get('/graphql', params=dict(
            query='query helloWho($who: String){ greet(who: $who) }',
            variables=json.dumps({'who': "ekampf"})
        ))

        response_dict = json.loads(response.body)
        self.assertDictEqual(
            response_dict.get('data'), {'greet': 'Hello ekampf!'}
        ) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:12,代码来源:test_graphql_handler.py

示例10: testPOST_support_json_variables

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def testPOST_support_json_variables(self):
        response = self.app.post('/graphql', params=json.dumps(dict(
            query='query helloWho($who: String){ greet(who: $who) }',
            variables={'who': "ekampf"}
        )))

        response_dict = json.loads(response.body)
        self.assertDictEqual(
            response_dict.get('data'), {'greet': 'Hello ekampf!'}
        ) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:12,代码来源:test_graphql_handler.py

示例11: test_handles_poorly_formed_variables

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def test_handles_poorly_formed_variables(self):
        for method in (self.get, self.post):
            response = method('/graphql', expect_errors=True, params=dict(
                query='query helloWho($who: String){ greet(who: $who) }',
                variables='who:You'
            ))

            response_data = json.loads(response.body)
            self.assertEqual(response.status_int, 400)
            self.assertEqual(response_data['errors'][0]['message'], 'Variables are invalid JSON.') 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:12,代码来源:test_graphql_handler.py

示例12: testStringProperty_shouldConvertToString

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def testStringProperty_shouldConvertToString(self):
        self.__assert_conversion(ndb.StringProperty, graphene.String) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:4,代码来源:test_converter.py

示例13: testStringProperty_repeated_shouldConvertToList

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def testStringProperty_repeated_shouldConvertToList(self):
        ndb_prop = ndb.StringProperty(repeated=True)
        result = convert_ndb_property(ndb_prop)
        graphene_type = result.field._type

        self.assertIsInstance(graphene_type, graphene.List)
        self.assertEqual(graphene_type.of_type, graphene.String) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:9,代码来源:test_converter.py

示例14: testStringProperty_required_shouldConvertToList

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def testStringProperty_required_shouldConvertToList(self):
        ndb_prop = ndb.StringProperty(required=True)
        result = convert_ndb_property(ndb_prop)
        graphene_type = result.field._type

        self.assertIsInstance(graphene_type, graphene.NonNull)
        self.assertEqual(graphene_type.of_type, graphene.String) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:9,代码来源:test_converter.py

示例15: testTextProperty_shouldConvertToString

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import String [as 别名]
def testTextProperty_shouldConvertToString(self):
        self.__assert_conversion(ndb.TextProperty, graphene.String) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:4,代码来源:test_converter.py


注:本文中的graphene.String方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。