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


Python graphql.parse方法代码示例

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


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

示例1: test_subscribe_bad_run_id

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_subscribe_bad_run_id(self, graphql_context):
        run_id = 'nope'
        subscription = execute_dagster_graphql(
            graphql_context, parse(SUBSCRIPTION_QUERY), variables={'runId': run_id}
        )

        subscribe_results = []
        subscription.subscribe(subscribe_results.append)

        assert len(subscribe_results) == 1
        subscribe_result = subscribe_results[0]

        assert (
            subscribe_result.data['pipelineRunLogs']['__typename']
            == 'PipelineRunLogsSubscriptionFailure'
        )
        assert subscribe_result.data['pipelineRunLogs']['missingRunId'] == 'nope' 
开发者ID:dagster-io,项目名称:dagster,代码行数:19,代码来源:test_execute_pipeline.py

示例2: test_basic_signature_with_fragments_in_various_order

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_basic_signature_with_fragments_in_various_order():
    operation = ""
    doc = parse(
        """
        fragment Bar on User {
          asd
        }
        {
          user {
            name
            ...Bar
          }
        }
        fragment Baz on User {
          jkl
        }
    """
    )
    assert (
        "fragment Bar on User{asd}{user{name...Bar}}"
        == default_engine_reporting_signature(doc, operation)
    ) 
开发者ID:graphql-python,项目名称:graphene-tornado,代码行数:24,代码来源:test_operation_id.py

示例3: generate_schema_hash

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def generate_schema_hash(schema: GraphQLSchema) -> str:
    """
    Generates a stable hash of the current schema using an introspection query.
    """
    ast = parse(introspection_query)
    result = cast(ExecutionResult, execute(schema, ast))

    if result and not result.data:
        raise GraphQLError("Unable to generate server introspection document")

    schema = result.data["__schema"]
    # It's important that we perform a deterministic stringification here
    # since, depending on changes in the underlying `graphql-core` execution
    # layer, varying orders of the properties in the introspection
    stringified_schema = stringify(schema).encode("utf-8")
    return hashlib.sha512(stringified_schema).hexdigest() 
开发者ID:graphql-python,项目名称:graphene-tornado,代码行数:18,代码来源:schema_utils.py

示例4: test_can_send_report_to_engine

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_can_send_report_to_engine(http_helper, snapshot):
    response = yield http_helper.get(url_string(query=QUERY), headers=GRAPHQL_HEADER)
    assert response.code == 200
    assert "data" in response_json(response)

    assert len(traces) == 1
    operation_name, document_ast, query_string, trace = traces[0]

    assert QUERY == query_string
    assert parse(QUERY) == document_ast
    assert "" == operation_name

    trace_json = MessageToJson(trace, sort_keys=True)
    trace_json = re.sub(r'"([0-9]+)"', '"-1"', trace_json)
    trace_json = re.sub(
        r'"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+Z"',
        '"2019-09-21T19:37:09.908919Z"',
        trace_json,
    )

    snapshot.assert_match(trace_json) 
开发者ID:graphql-python,项目名称:graphene-tornado,代码行数:23,代码来源:test_engine_extension.py

示例5: test_maintains_skip_and_include_directives

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_maintains_skip_and_include_directives():
    body = """
    schema {
        query: Hello
    }

    type Hello {
        str: String
    }
    """

    schema = build_ast_schema(parse(body))
    assert len(schema.get_directives()) == 3
    assert schema.get_directive("skip") == GraphQLSkipDirective
    assert schema.get_directive("include") == GraphQLIncludeDirective
    assert schema.get_directive("deprecated") == GraphQLDeprecatedDirective 
开发者ID:graphql-python,项目名称:graphql-core-legacy,代码行数:18,代码来源:test_build_ast_schema.py

示例6: test_overriding_directives_excludes_specified

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_overriding_directives_excludes_specified():
    body = """
    schema {
        query: Hello
    }

    directive @skip on FIELD
    directive @include on FIELD
    directive @deprecated on FIELD_DEFINITION

    type Hello {
        str: String
    }
    """

    schema = build_ast_schema(parse(body))
    assert len(schema.get_directives()) == 3
    assert schema.get_directive("skip") != GraphQLSkipDirective
    assert schema.get_directive("skip") is not None
    assert schema.get_directive("include") != GraphQLIncludeDirective
    assert schema.get_directive("include") is not None
    assert schema.get_directive("deprecated") != GraphQLDeprecatedDirective
    assert schema.get_directive("deprecated") is not None 
开发者ID:graphql-python,项目名称:graphql-core-legacy,代码行数:25,代码来源:test_build_ast_schema.py

示例7: test_overriding_skip_directive_excludes_built_in_one

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_overriding_skip_directive_excludes_built_in_one():
    body = """
    schema {
        query: Hello
    }

    directive @skip on FIELD

    type Hello {
        str: String
    }
    """

    schema = build_ast_schema(parse(body))
    assert len(schema.get_directives()) == 3
    assert schema.get_directive("skip") != GraphQLSkipDirective
    assert schema.get_directive("skip") is not None
    assert schema.get_directive("include") == GraphQLIncludeDirective
    assert schema.get_directive("deprecated") == GraphQLDeprecatedDirective 
开发者ID:graphql-python,项目名称:graphql-core-legacy,代码行数:21,代码来源:test_build_ast_schema.py

示例8: test_adding_directives_maintains_skip_and_include_directives

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_adding_directives_maintains_skip_and_include_directives():
    body = """
    schema {
        query: Hello
    }

    directive @foo(arg: Int) on FIELD

    type Hello {
        str: String
    }
    """

    schema = build_ast_schema(parse(body))
    assert len(schema.get_directives()) == 4
    assert schema.get_directive("skip") == GraphQLSkipDirective
    assert schema.get_directive("include") == GraphQLIncludeDirective
    assert schema.get_directive("deprecated") == GraphQLDeprecatedDirective 
开发者ID:graphql-python,项目名称:graphql-core-legacy,代码行数:20,代码来源:test_build_ast_schema.py

示例9: test_input_types_are_read

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_input_types_are_read():
    schema = build_ast_schema(
        parse(
            """
        schema {
            query: Query
        }

        type Query {
            field(input: Input): Int
        }

        input Input {
            id: Int
        }
    """
        )
    )

    input_type = schema.get_type("Input")
    assert input_type.fields["id"].type == GraphQLInt 
开发者ID:graphql-python,项目名称:graphql-core-legacy,代码行数:23,代码来源:test_build_ast_schema.py

示例10: test_input_types_can_be_recursive

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_input_types_can_be_recursive():
    schema = build_ast_schema(
        parse(
            """
        schema {
            query: Query
        }

        type Query {
            field(input: Input): Int
        }

        input Input {
            id: Input
        }
    """
        )
    )

    input_type = schema.get_type("Input")
    assert input_type.fields["id"].type == input_type 
开发者ID:graphql-python,项目名称:graphql-core-legacy,代码行数:23,代码来源:test_build_ast_schema.py

示例11: test_allows_only_a_single_schema_definition

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_allows_only_a_single_schema_definition():
    body = """
schema {
  query: Hello
}

schema {
  query: Hello
}

type Hello {
  bar: Bar
}
"""
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc)

    assert "Must provide only one schema definition." == str(excinfo.value) 
开发者ID:graphql-python,项目名称:graphql-core-legacy,代码行数:21,代码来源:test_build_ast_schema.py

示例12: test_allows_only_a_single_query_type

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_allows_only_a_single_query_type():
    body = """
schema {
  query: Hello
  query: Yellow
}

type Hello {
  bar: Bar
}

type Yellow {
  isColor: Boolean
}
"""
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc)

    assert "Must provide only one query type in schema." == str(excinfo.value) 
开发者ID:graphql-python,项目名称:graphql-core-legacy,代码行数:22,代码来源:test_build_ast_schema.py

示例13: test_allows_only_a_single_mutation_type

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_allows_only_a_single_mutation_type():
    body = """
schema {
  query: Hello
  mutation: Hello
  mutation: Yellow
}

type Hello {
  bar: Bar
}

type Yellow {
  isColor: Boolean
}
"""
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc)

    assert "Must provide only one mutation type in schema." == str(excinfo.value) 
开发者ID:graphql-python,项目名称:graphql-core-legacy,代码行数:23,代码来源:test_build_ast_schema.py

示例14: test_allows_only_a_single_subscription_type

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_allows_only_a_single_subscription_type():
    body = """
schema {
  query: Hello
  subscription: Hello
  subscription: Yellow
}

type Hello {
  bar: Bar
}

type Yellow {
  isColor: Boolean
}
"""
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc)

    assert "Must provide only one subscription type in schema." == str(excinfo.value) 
开发者ID:graphql-python,项目名称:graphql-core-legacy,代码行数:23,代码来源:test_build_ast_schema.py

示例15: test_unknown_mutation_type

# 需要导入模块: import graphql [as 别名]
# 或者: from graphql import parse [as 别名]
def test_unknown_mutation_type():
    body = """
schema {
  query: Hello
  mutation: Wat
}

type Hello {
  str: String
}
"""
    doc = parse(body)
    with raises(Exception) as excinfo:
        build_ast_schema(doc)

    assert 'Specified mutation type "Wat" not found in document' in str(excinfo.value) 
开发者ID:graphql-python,项目名称:graphql-core-legacy,代码行数:18,代码来源:test_build_ast_schema.py


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