當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。