_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q29900 | do_types_overlap | train | def do_types_overlap(schema, type_a, type_b):
"""Check whether two types overlap in a given schema.
Provided two composite types, determine if they "overlap". Two composite types
overlap when the Sets of possible concrete types for each intersect.
This is often used to determine if a fragment of a giv... | python | {
"resource": ""
} |
q29901 | concat_ast | train | def concat_ast(asts: Sequence[DocumentNode]) -> DocumentNode:
"""Concat ASTs.
Provided a collection of ASTs, presumably each from different files, concatenate
the ASTs together into batched AST, useful for validating many GraphQL source files
which together represent | python | {
"resource": ""
} |
q29902 | suggestion_list | train | def suggestion_list(input_: str, options: Collection[str]):
"""Get list with suggestions for a given input.
Given an invalid input string and list of valid options, returns a filtered list
of valid options sorted based on their similarity with the input.
"""
options_by_distance = {}
input_thres... | python | {
"resource": ""
} |
q29903 | lexical_distance | train | def lexical_distance(a_str: str, b_str: str) -> int:
"""Computes the lexical distance between strings A and B.
The "distance" between two strings is given by counting the minimum number of edits
needed to transform string A into string B. An edit can be an insertion, deletion,
or substitution of a sing... | python | {
"resource": ""
} |
q29904 | get_operation_ast | train | def get_operation_ast(
document_ast: DocumentNode, operation_name: Optional[str] = None
) -> Optional[OperationDefinitionNode]:
"""Get operation AST node.
Returns an operation AST given a document AST and optionally an operation
name. If a name is not provided, an operation is only returned if only one... | python | {
"resource": ""
} |
q29905 | format_error | train | def format_error(error: "GraphQLError") -> dict:
"""Format a GraphQL error
Given a GraphQLError, format it according to the rules described by the "Response
Format, Errors" section of the GraphQL Specification.
"""
if not error:
raise ValueError("Received null or undefined error.")
form... | python | {
"resource": ""
} |
q29906 | graphql | train | async def graphql(
schema: GraphQLSchema,
source: Union[str, Source],
root_value: Any = None,
context_value: Any = None,
variable_values: Dict[str, Any] = None,
operation_name: str = None,
field_resolver: GraphQLFieldResolver = None,
type_resolver: GraphQLTypeResolver = None,
middlew... | python | {
"resource": ""
} |
q29907 | graphql_impl | train | def graphql_impl(
schema,
source,
root_value,
context_value,
variable_values,
operation_name,
field_resolver,
type_resolver,
middleware,
execution_context_class,
) -> AwaitableOrValue[ExecutionResult]:
"""Execute a query, return asynchronously only if necessary."""
# Vali... | python | {
"resource": ""
} |
q29908 | get_named_type | train | def get_named_type(type_): # noqa: F811
"""Unwrap possible wrapping type"""
if type_:
unwrapped_type = type_
while is_wrapping_type(unwrapped_type):
unwrapped_type = cast(GraphQLWrappingType, unwrapped_type)
| python | {
"resource": ""
} |
q29909 | get_nullable_type | train | def get_nullable_type(type_): # noqa: F811
"""Unwrap possible non-null type"""
if is_non_null_type(type_):
type_ = cast(GraphQLNonNull, type_)
| python | {
"resource": ""
} |
q29910 | GraphQLObjectType.fields | train | def fields(self) -> GraphQLFieldMap:
"""Get provided fields, wrapping them as GraphQLFields if needed."""
try:
fields = resolve_thunk(self._fields)
except GraphQLError:
raise
except Exception as error:
raise TypeError(f"{self.name} fields cannot be res... | python | {
"resource": ""
} |
q29911 | GraphQLObjectType.interfaces | train | def interfaces(self) -> GraphQLInterfaceList:
"""Get provided interfaces."""
try:
interfaces = resolve_thunk(self._interfaces)
except GraphQLError:
raise
except Exception as error:
raise TypeError(f"{self.name} interfaces cannot be resolved: {error}")
... | python | {
"resource": ""
} |
q29912 | GraphQLUnionType.types | train | def types(self) -> GraphQLTypeList:
"""Get provided types."""
try:
types = resolve_thunk(self._types)
except GraphQLError:
raise
except Exception as error:
raise TypeError(f"{self.name} types cannot be resolved: {error}")
if types is None:
... | python | {
"resource": ""
} |
q29913 | GraphQLInputObjectType.fields | train | def fields(self) -> GraphQLInputFieldMap:
"""Get provided fields, wrap them as GraphQLInputField if needed."""
try:
fields = resolve_thunk(self._fields)
except GraphQLError:
raise
except Exception as error:
raise TypeError(f"{self.name} fields cannot b... | python | {
"resource": ""
} |
q29914 | located_error | train | def located_error(
original_error: Union[Exception, GraphQLError],
nodes: Sequence["Node"],
path: Sequence[Union[str, int]],
) -> GraphQLError:
"""Located GraphQL Error
Given an arbitrary Error, presumably thrown while attempting to execute a GraphQL
operation, produce a new GraphQLError aware ... | python | {
"resource": ""
} |
q29915 | assert_valid_name | train | def assert_valid_name(name: str) -> str:
"""Uphold the spec rules | python | {
"resource": ""
} |
q29916 | is_valid_name_error | train | def is_valid_name_error(name: str, node: Node = None) -> Optional[GraphQLError]:
"""Return an Error if a name is invalid."""
if not isinstance(name, str):
raise TypeError("Expected string")
if name.startswith("__"):
| python | {
"resource": ""
} |
q29917 | subscribe | train | async def subscribe(
schema: GraphQLSchema,
document: DocumentNode,
root_value: Any = None,
context_value: Any = None,
variable_values: Dict[str, Any] = None,
operation_name: str = None,
field_resolver: GraphQLFieldResolver = None,
subscribe_field_resolver: GraphQLFieldResolver = None,
)... | python | {
"resource": ""
} |
q29918 | create_source_event_stream | train | async def create_source_event_stream(
schema: GraphQLSchema,
document: DocumentNode,
root_value: Any = None,
context_value: Any = None,
variable_values: Dict[str, Any] = None,
operation_name: str = None,
field_resolver: GraphQLFieldResolver = None,
) -> Union[AsyncIterable[Any], ExecutionRes... | python | {
"resource": ""
} |
q29919 | Visitor.get_visit_fn | train | def get_visit_fn(cls, kind, is_leaving=False) -> Callable:
"""Get the visit function for the given node kind and direction."""
method = "leave" if is_leaving else "enter"
| python | {
"resource": ""
} |
q29920 | validate_schema | train | def validate_schema(schema: GraphQLSchema) -> List[GraphQLError]:
"""Validate a GraphQL schema.
Implements the "Type Validation" sub-sections of the specification's "Type System"
section.
Validation runs synchronously, returning a list of encountered errors, or an empty
list if no errors were enco... | python | {
"resource": ""
} |
q29921 | assert_valid_schema | train | def assert_valid_schema(schema: GraphQLSchema) -> None:
"""Utility function which asserts a schema is valid.
Throws a TypeError if the schema is invalid.
"""
errors | python | {
"resource": ""
} |
q29922 | separate_operations | train | def separate_operations(document_ast: DocumentNode) -> Dict[str, DocumentNode]:
"""Separate operations in a given AST document.
This function accepts a single AST document which may contain many operations and
fragments and returns a collection of AST documents each of which contains a single
operation... | python | {
"resource": ""
} |
q29923 | collect_transitive_dependencies | train | def collect_transitive_dependencies(
collected: Set[str], dep_graph: DepGraph, from_name: str
) -> None:
"""Collect transitive dependencies.
From a dependency graph, collects a list of transitive dependencies by recursing
through a dependency graph.
"""
| python | {
"resource": ""
} |
q29924 | ast_from_value | train | def ast_from_value(value: Any, type_: GraphQLInputType) -> Optional[ValueNode]:
"""Produce a GraphQL Value AST given a Python value.
A GraphQL type must be provided, which will be used to interpret different Python
values.
| JSON Value | GraphQL Value |
| ------------- | ----------------... | python | {
"resource": ""
} |
q29925 | get_variable_values | train | def get_variable_values(
schema: GraphQLSchema,
var_def_nodes: List[VariableDefinitionNode],
inputs: Dict[str, Any],
) -> CoercedVariableValues:
"""Get coerced variable values based on provided definitions.
Prepares a dict of variable values of the correct type based on the provided
variable de... | python | {
"resource": ""
} |
q29926 | get_argument_values | train | def get_argument_values(
type_def: Union[GraphQLField, GraphQLDirective],
node: Union[FieldNode, DirectiveNode],
variable_values: Dict[str, Any] = None,
) -> Dict[str, Any]:
"""Get coerced argument values based on provided definitions and nodes.
Prepares an dict of argument values given a list of a... | python | {
"resource": ""
} |
q29927 | get_directive_values | train | def get_directive_values(
directive_def: GraphQLDirective,
node: NodeWithDirective,
variable_values: Dict[str, Any] = None,
) -> Optional[Dict[str, Any]]:
"""Get coerced argument values based on provided nodes.
Prepares a dict of argument values given a directive definition and an AST node
whic... | python | {
"resource": ""
} |
q29928 | build_ast_schema | train | def build_ast_schema(
document_ast: DocumentNode,
assume_valid: bool = False,
assume_valid_sdl: bool = False,
) -> GraphQLSchema:
"""Build a GraphQL Schema from a given AST.
This takes the ast of a schema document produced by the parse function in
src/language/parser.py.
If no schema defin... | python | {
"resource": ""
} |
q29929 | get_deprecation_reason | train | def get_deprecation_reason(
node: Union[EnumValueDefinitionNode, FieldDefinitionNode]
) -> Optional[str]:
"""Given a field or enum value node, get deprecation reason as string."""
from ..execution import get_directive_values
| python | {
"resource": ""
} |
q29930 | build_schema | train | def build_schema(
source: Union[str, Source],
assume_valid=False,
assume_valid_sdl=False,
no_location=False,
experimental_fragment_variables=False,
) -> GraphQLSchema:
"""Build a GraphQLSchema directly from a source document."""
return build_ast_schema(
parse(
source,
| python | {
"resource": ""
} |
q29931 | validate | train | def validate(
schema: GraphQLSchema,
document_ast: DocumentNode,
rules: Sequence[RuleType] = None,
type_info: TypeInfo = None,
) -> List[GraphQLError]:
"""Implements the "Validation" section of the spec.
Validation runs synchronously, returning a list of encountered errors, or an empty
list... | python | {
"resource": ""
} |
q29932 | validate_sdl | train | def validate_sdl(
document_ast: DocumentNode,
schema_to_extend: GraphQLSchema = None,
rules: Sequence[RuleType] = None,
) -> List[GraphQLError]:
"""Validate an SDL document."""
context = SDLValidationContext(document_ast, schema_to_extend)
if rules is None:
| python | {
"resource": ""
} |
q29933 | assert_valid_sdl | train | def assert_valid_sdl(document_ast: DocumentNode) -> None:
"""Assert document is valid SDL.
Utility function which asserts a SDL document is valid by throwing an error if it
is invalid.
| python | {
"resource": ""
} |
q29934 | assert_valid_sdl_extension | train | def assert_valid_sdl_extension(
document_ast: DocumentNode, schema: GraphQLSchema
) -> None:
"""Assert document is a valid SDL extension.
Utility function which | python | {
"resource": ""
} |
q29935 | type_from_ast | train | def type_from_ast(schema, type_node): # noqa: F811
"""Get the GraphQL type definition from an AST node.
Given a Schema and an AST node describing a type, return a GraphQLType definition
which applies to that type. For example, if provided the parsed AST node for
`[User]`, a GraphQLList instance will b... | python | {
"resource": ""
} |
q29936 | get_suggested_type_names | train | def get_suggested_type_names(
schema: GraphQLSchema, type_: GraphQLOutputType, field_name: str
) -> List[str]:
"""
Get a list of suggested type names.
Go through all of the implementations of type, as well as the interfaces
that they implement. If any of those types include the provided field,
... | python | {
"resource": ""
} |
q29937 | get_suggested_field_names | train | def get_suggested_field_names(type_: GraphQLOutputType, field_name: str) -> List[str]:
"""Get a list of suggested field names.
For the field name provided, determine if there are any similar field names that may
be the result of a typo.
"""
if is_object_type(type_) or is_interface_type(type_):
... | python | {
"resource": ""
} |
q29938 | parse | train | def parse(
source: SourceType, no_location=False, experimental_fragment_variables=False
) -> DocumentNode:
"""Given a GraphQL source, parse it into a Document.
Throws GraphQLError if a syntax error is encountered.
By default, the parser creates AST nodes that know the location in the source that
t... | python | {
"resource": ""
} |
q29939 | parse_value | train | def parse_value(source: SourceType, **options: dict) -> ValueNode:
"""Parse the AST for a given string containing a GraphQL value.
Throws GraphQLError if a syntax error is encountered.
This is useful within tools that operate upon GraphQL Values directly and in
isolation of complete GraphQL documents.... | python | {
"resource": ""
} |
q29940 | parse_type | train | def parse_type(source: SourceType, **options: dict) -> TypeNode:
"""Parse the AST for a given string containing a GraphQL Type.
Throws GraphQLError if a syntax error is encountered.
This is useful within tools that operate upon GraphQL Types directly and
in isolation of complete GraphQL documents.
... | python | {
"resource": ""
} |
q29941 | parse_name | train | def parse_name(lexer: Lexer) -> NameNode:
"""Convert a name lex token into a name parse node."""
token = expect_token(lexer, | python | {
"resource": ""
} |
q29942 | parse_fragment | train | def parse_fragment(lexer: Lexer) -> Union[FragmentSpreadNode, InlineFragmentNode]:
"""Corresponds to both FragmentSpread and InlineFragment in the spec.
FragmentSpread: ... FragmentName Directives?
InlineFragment: ... TypeCondition? Directives? SelectionSet
"""
start = lexer.token
expect_token(... | python | {
"resource": ""
} |
q29943 | loc | train | def loc(lexer: Lexer, start_token: Token) -> Optional[Location]:
"""Return a location object.
Used to identify the place in the source that created a given parsed object.
"""
if not lexer.no_location:
end_token = lexer.last_token
source = lexer.source | python | {
"resource": ""
} |
q29944 | expect_token | train | def expect_token(lexer: Lexer, kind: TokenKind) -> Token:
"""Expect the next token to be of the given kind.
If the next token is of the given kind, return that token after advancing the lexer.
Otherwise, do not change the parser state and throw an error.
"""
token = lexer.token
if token.kind ==... | python | {
"resource": ""
} |
q29945 | expect_optional_token | train | def expect_optional_token(lexer: Lexer, kind: TokenKind) -> Optional[Token]:
"""Expect the next token optionally to be of the given kind.
If the next token is of the given kind, return that token after advancing the lexer.
Otherwise, do not | python | {
"resource": ""
} |
q29946 | expect_keyword | train | def expect_keyword(lexer: Lexer, value: str) -> Token:
"""Expect the next token to be a given keyword.
If the next token is a given keyword, return that token after advancing the lexer.
Otherwise, do not change the parser state and throw an error.
"""
token = lexer.token
if token.kind == TokenK... | python | {
"resource": ""
} |
q29947 | expect_optional_keyword | train | def expect_optional_keyword(lexer: Lexer, value: str) -> Optional[Token]:
"""Expect the next token optionally to be a given keyword.
If the next token is a given keyword, return that | python | {
"resource": ""
} |
q29948 | unexpected | train | def unexpected(lexer: Lexer, at_token: Token = None) -> GraphQLError:
"""Create an error when an unexpected lexed | python | {
"resource": ""
} |
q29949 | many_nodes | train | def many_nodes(
lexer: Lexer,
open_kind: TokenKind,
parse_fn: Callable[[Lexer], Node],
close_kind: TokenKind,
) -> List[Node]:
"""Fetch matching nodes, at least one.
Returns a non-empty list of parse nodes, determined by the `parse_fn`.
This list begins with a lex token of `open_kind` and e... | python | {
"resource": ""
} |
q29950 | coercion_error | train | def coercion_error(
message: str,
blame_node: Node = None,
path: Path = None,
sub_message: str = None,
original_error: Exception = None,
) -> GraphQLError:
"""Return a GraphQLError instance"""
if path:
path_str = print_path(path)
message += f" at {path_str}"
message | python | {
"resource": ""
} |
q29951 | print_path | train | def print_path(path: Path) -> str:
"""Build string describing the path into the value where error was found"""
path_str = ""
current_path: Optional[Path] = path
while current_path:
path_str = (
f".{current_path.key}"
| python | {
"resource": ""
} |
q29952 | parse_int_literal | train | def parse_int_literal(ast, _variables=None):
"""Parse an integer value node in the AST."""
if isinstance(ast, IntValueNode):
num = int(ast.value)
| python | {
"resource": ""
} |
q29953 | parse_float_literal | train | def parse_float_literal(ast, _variables=None):
"""Parse a float value node in the AST."""
if isinstance(ast, (FloatValueNode, | python | {
"resource": ""
} |
q29954 | parse_id_literal | train | def parse_id_literal(ast, _variables=None):
"""Parse an ID value node in the AST."""
if isinstance(ast, (StringValueNode, | python | {
"resource": ""
} |
q29955 | find_breaking_changes | train | def find_breaking_changes(
old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> List[BreakingChange]:
"""Find breaking changes.
Given two schemas, returns a list containing descriptions of all the types of
breaking changes covered by the other functions down below.
"""
return (
fin... | python | {
"resource": ""
} |
q29956 | find_dangerous_changes | train | def find_dangerous_changes(
old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> List[DangerousChange]:
"""Find dangerous changes.
Given two schemas, returns a list containing descriptions of all the types of
potentially dangerous changes covered by the other functions down below.
"""
retu... | python | {
"resource": ""
} |
q29957 | find_removed_types | train | def find_removed_types(
old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> List[BreakingChange]:
"""Find removed types.
Given two schemas, returns a list containing descriptions of any breaking changes
in the newSchema related to removing an entire type.
"""
old_type_map = old_schema.typ... | python | {
"resource": ""
} |
q29958 | find_types_that_changed_kind | train | def find_types_that_changed_kind(
old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> List[BreakingChange]:
"""Find types that changed kind
Given two schemas, returns a list containing descriptions of any breaking changes
in the newSchema related to changing the type of a type.
"""
old_ty... | python | {
"resource": ""
} |
q29959 | find_arg_changes | train | def find_arg_changes(
old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> BreakingAndDangerousChanges:
"""Find argument changes.
Given two schemas, returns a list containing descriptions of any breaking or
dangerous changes in the new_schema related to arguments (such as removal or change
of ... | python | {
"resource": ""
} |
q29960 | find_types_removed_from_unions | train | def find_types_removed_from_unions(
old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> List[BreakingChange]:
"""Find types removed from unions.
Given two schemas, returns a list containing descriptions of any breaking changes
in the new_schema related to removing types from a union type.
"""... | python | {
"resource": ""
} |
q29961 | find_types_added_to_unions | train | def find_types_added_to_unions(
old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> List[DangerousChange]:
"""Find types added to union.
Given two schemas, returns a list containing descriptions of any dangerous changes
in the new_schema related to adding types to a union type.
"""
old_ty... | python | {
"resource": ""
} |
q29962 | find_values_removed_from_enums | train | def find_values_removed_from_enums(
old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> List[BreakingChange]:
"""Find values removed from enums.
Given two schemas, returns a list containing descriptions of any breaking changes
in the new_schema related to removing values from an enum type.
""... | python | {
"resource": ""
} |
q29963 | find_values_added_to_enums | train | def find_values_added_to_enums(
old_schema: GraphQLSchema, new_schema: GraphQLSchema
) -> List[DangerousChange]:
"""Find values added to enums.
Given two schemas, returns a list containing descriptions of any dangerous changes
in the new_schema related to adding values to an enum type.
"""
old_... | python | {
"resource": ""
} |
q29964 | is_finite | train | def is_finite(value: Any) -> bool:
"""Return true if a value is a | python | {
"resource": ""
} |
q29965 | find_conflicts_within_selection_set | train | def find_conflicts_within_selection_set(
context: ValidationContext,
cached_fields_and_fragment_names: Dict,
compared_fragment_pairs: "PairSet",
parent_type: Optional[GraphQLNamedType],
selection_set: SelectionSetNode,
) -> List[Conflict]:
"""Find conflicts within selection set.
Find all co... | python | {
"resource": ""
} |
q29966 | collect_conflicts_between_fields_and_fragment | train | def collect_conflicts_between_fields_and_fragment(
context: ValidationContext,
conflicts: List[Conflict],
cached_fields_and_fragment_names: Dict,
compared_fragments: Set[str],
compared_fragment_pairs: "PairSet",
are_mutually_exclusive: bool,
field_map: NodeAndDefCollection,
fragment_name... | python | {
"resource": ""
} |
q29967 | collect_conflicts_between_fragments | train | def collect_conflicts_between_fragments(
context: ValidationContext,
conflicts: List[Conflict],
cached_fields_and_fragment_names: Dict,
compared_fragment_pairs: "PairSet",
are_mutually_exclusive: bool,
fragment_name1: str,
fragment_name2: str,
) -> None:
"""Collect conflicts between frag... | python | {
"resource": ""
} |
q29968 | find_conflicts_between_sub_selection_sets | train | def find_conflicts_between_sub_selection_sets(
context: ValidationContext,
cached_fields_and_fragment_names: Dict,
compared_fragment_pairs: "PairSet",
are_mutually_exclusive: bool,
parent_type1: Optional[GraphQLNamedType],
selection_set1: SelectionSetNode,
parent_type2: Optional[GraphQLNamed... | python | {
"resource": ""
} |
q29969 | find_conflict | train | def find_conflict(
context: ValidationContext,
cached_fields_and_fragment_names: Dict,
compared_fragment_pairs: "PairSet",
parent_fields_are_mutually_exclusive: bool,
response_name: str,
field1: NodeAndDef,
field2: NodeAndDef,
) -> Optional[Conflict]:
"""Find conflict.
Determines if... | python | {
"resource": ""
} |
q29970 | do_types_conflict | train | def do_types_conflict(type1: GraphQLOutputType, type2: GraphQLOutputType) -> bool:
"""Check whether two types conflict
Two types conflict if both types could not apply to a value simultaneously.
Composite types are ignored as their individual field types will be compared later
recursively. However List... | python | {
"resource": ""
} |
q29971 | get_fields_and_fragment_names | train | def get_fields_and_fragment_names(
context: ValidationContext,
cached_fields_and_fragment_names: Dict,
parent_type: Optional[GraphQLNamedType],
selection_set: SelectionSetNode,
) -> Tuple[NodeAndDefCollection, List[str]]:
"""Get fields and referenced fragment names
Given a selection set, return... | python | {
"resource": ""
} |
q29972 | get_referenced_fields_and_fragment_names | train | def get_referenced_fields_and_fragment_names(
context: ValidationContext,
cached_fields_and_fragment_names: Dict,
fragment: FragmentDefinitionNode,
) -> Tuple[NodeAndDefCollection, List[str]]:
"""Get referenced fields and nested fragment names
Given a reference to a fragment, return the represented... | python | {
"resource": ""
} |
q29973 | subfield_conflicts | train | def subfield_conflicts(
conflicts: List[Conflict], response_name: str, node1: FieldNode, node2: FieldNode
) -> Optional[Conflict]:
"""Check whether there are conflicts between sub-fields.
Given a series of Conflicts which occurred between two sub-fields, generate a single
Conflict.
"""
if confl... | python | {
"resource": ""
} |
q29974 | EventEmitter.add_listener | train | def add_listener(self, event_name: str, listener: Callable):
| python | {
"resource": ""
} |
q29975 | EventEmitter.remove_listener | train | def remove_listener(self, event_name, listener):
"""Removes a listener."""
| python | {
"resource": ""
} |
q29976 | introspection_from_schema | train | def introspection_from_schema(
schema: GraphQLSchema, descriptions: bool = True
) -> IntrospectionSchema:
"""Build an IntrospectionQuery from a GraphQLSchema
IntrospectionQuery is useful for utilities that care about type and field
relationships, but do not need to traverse through those relationships.... | python | {
"resource": ""
} |
q29977 | find_deprecated_usages | train | def find_deprecated_usages(
schema: GraphQLSchema, ast: DocumentNode
) -> List[GraphQLError]:
"""Get a list of GraphQLError instances describing each deprecated use."""
type_info = TypeInfo(schema)
visitor = | python | {
"resource": ""
} |
q29978 | snake_to_camel | train | def snake_to_camel(s, upper=True):
"""Convert from snake_case to CamelCase
If upper is set, then convert to upper CamelCase, otherwise the first character
keeps its case.
"""
| python | {
"resource": ""
} |
q29979 | ValuesOfCorrectTypeRule.is_valid_scalar | train | def is_valid_scalar(self, node: ValueNode) -> None:
"""Check whether this is a valid scalar.
Any value literal may be a valid representation of a Scalar, depending on that
scalar type.
"""
# Report any error at the full type expected by the location.
location_type = self... | python | {
"resource": ""
} |
q29980 | is_missing_variable | train | def is_missing_variable(
value_node: ValueNode, variables: Dict[str, Any] = None
) -> bool:
"""Check if `value_node` is a variable not defined in the `variables` dict."""
| python | {
"resource": ""
} |
q29981 | is_integer | train | def is_integer(value: Any) -> bool:
"""Return true if a value is an integer number."""
return (isinstance(value, | python | {
"resource": ""
} |
q29982 | allowed_variable_usage | train | def allowed_variable_usage(
schema: GraphQLSchema,
var_type: GraphQLType,
var_default_value: Optional[ValueNode],
location_type: GraphQLType,
location_default_value: Any,
) -> bool:
"""Check for allowed variable usage.
Returns True if the variable is allowed in the location it was found, wh... | python | {
"resource": ""
} |
q29983 | is_schema_of_common_names | train | def is_schema_of_common_names(schema: GraphQLSchema) -> bool:
"""Check whether this schema uses the common naming convention.
GraphQL schema define root types for each type of operation. These types are the
same as any other type and can be named in any manner, however there is a common
naming conventi... | python | {
"resource": ""
} |
q29984 | print_value | train | def print_value(value: Any, type_: GraphQLInputType) -> str:
"""Convenience function for printing a | python | {
"resource": ""
} |
q29985 | add_description | train | def add_description(method):
"""Decorator adding the description to the output of a visitor method."""
@wraps(method)
def wrapped(self, node, *args):
| python | {
"resource": ""
} |
q29986 | join | train | def join(strings: Optional[Sequence[str]], separator: str = "") -> str:
"""Join strings in a given sequence.
Return an empty string if it is None or empty, otherwise join all items together
separated | python | {
"resource": ""
} |
q29987 | wrap | train | def wrap(start: str, string: str, end: str = "") -> str:
"""Wrap string inside other strings at start and end.
If the string is not None or empty, then wrap with start and | python | {
"resource": ""
} |
q29988 | has_multiline_items | train | def has_multiline_items(maybe_list: Optional[Sequence[str]]):
"""Check whether one of the items in the list has multiple | python | {
"resource": ""
} |
q29989 | get_middleware_resolvers | train | def get_middleware_resolvers(middlewares: Tuple[Any, ...]) -> Iterator[Callable]:
"""Get a list of resolver functions from a list of classes or functions."""
for middleware in middlewares:
if isfunction(middleware):
yield middleware
else: # middleware | python | {
"resource": ""
} |
q29990 | MiddlewareManager.get_field_resolver | train | def get_field_resolver(
self, field_resolver: GraphQLFieldResolver
) -> GraphQLFieldResolver:
"""Wrap the provided resolver with the middleware.
Returns a function that chains the middleware functions with the provided
resolver function.
"""
| python | {
"resource": ""
} |
q29991 | type_map_reducer | train | def type_map_reducer(map_: TypeMap, type_: GraphQLNamedType = None) -> TypeMap:
"""Reducer function for creating the type map from given types."""
if not type_:
return map_
if is_wrapping_type(type_):
return type_map_reducer(
map_, cast(GraphQLWrappingType[GraphQLNamedType], type... | python | {
"resource": ""
} |
q29992 | type_map_directive_reducer | train | def type_map_directive_reducer(
map_: TypeMap, directive: GraphQLDirective = None
) -> TypeMap:
"""Reducer function for creating the type map from given directives."""
# Directives are not validated until validate_schema() | python | {
"resource": ""
} |
q29993 | GraphQLSchema.get_possible_types | train | def get_possible_types(
self, abstract_type: GraphQLAbstractType
) -> Sequence[GraphQLObjectType]:
"""Get list of all possible concrete types for given abstract type."""
if is_union_type(abstract_type):
| python | {
"resource": ""
} |
q29994 | GraphQLSchema.is_possible_type | train | def is_possible_type(
self, abstract_type: GraphQLAbstractType, possible_type: GraphQLObjectType
) -> bool:
"""Check whether a concrete type is possible for an abstract type."""
possible_type_map = self._possible_type_map
try:
possible_type_names = possible_type_map[abstr... | python | {
"resource": ""
} |
q29995 | byte_adaptor | train | def byte_adaptor(fbuffer):
""" provides py3 compatibility by converting byte based
file stream to string based file stream
Arguments:
fbuffer: file like objects containing bytes
Returns:
string buffer
"""
if six.PY3:
| python | {
"resource": ""
} |
q29996 | js_adaptor | train | def js_adaptor(buffer):
""" convert javascript objects like true, none, NaN etc. to
quoted word.
Arguments:
buffer: string to be converted
Returns: | python | {
"resource": ""
} |
q29997 | Nse.get_bhavcopy_url | train | def get_bhavcopy_url(self, d):
"""take date and return bhavcopy url"""
d = parser.parse(d).date()
day_of_month = d.strftime("%d")
mon = d.strftime("%b").upper()
| python | {
"resource": ""
} |
q29998 | Nse.download_bhavcopy | train | def download_bhavcopy(self, d):
"""returns bhavcopy as csv file."""
# ex_url = "https://www.nseindia.com/content/historical/EQUITIES/2011/NOV/cm08NOV2011bhav.csv.zip"
url = self.get_bhavcopy_url(d)
filename = self.get_bhavcopy_filename(d)
# response = requests.get(url, headers=se... | python | {
"resource": ""
} |
q29999 | _replace_numeric_markers | train | def _replace_numeric_markers(operation, string_parameters):
"""
Replaces qname, format, and numeric markers in the given operation, from
the string_parameters list.
Raises ProgrammingError on wrong number of parameters or bindings
when using qmark. There is no error checking on numeric parameters.
... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.