nwo
stringlengths
10
28
sha
stringlengths
40
40
path
stringlengths
11
97
identifier
stringlengths
1
64
parameters
stringlengths
2
2.24k
return_statement
stringlengths
0
2.17k
docstring
stringlengths
0
5.45k
docstring_summary
stringlengths
0
3.83k
func_begin
int64
1
13.4k
func_end
int64
2
13.4k
function
stringlengths
28
56.4k
url
stringlengths
106
209
project
int64
1
48
executed_lines
list
executed_lines_pc
float64
0
153
missing_lines
list
missing_lines_pc
float64
0
100
covered
bool
2 classes
filecoverage
float64
2.53
100
function_lines
int64
2
1.46k
mccabe
int64
1
253
coverage
float64
0
100
docstring_lines
int64
0
112
function_nodoc
stringlengths
9
56.4k
id
int64
0
29.8k
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/utils/resolve_only_args.py
resolve_only_args
(func)
return wrapped_func
7
12
def resolve_only_args(func): @wraps(func) def wrapped_func(root, info, **args): return func(root, **args) return wrapped_func
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/utils/resolve_only_args.py#L7-L12
30
[ 0 ]
16.666667
[ 1, 2, 3, 5 ]
66.666667
false
50
6
2
33.333333
0
def resolve_only_args(func): @wraps(func) def wrapped_func(root, info, **args): return func(root, **args) return wrapped_func
20,669
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/utils/subclass_with_meta.py
SubclassWithMeta_Meta.__str__
(cls)
return cls.__name__
9
12
def __str__(cls): if cls._meta: return cls._meta.name return cls.__name__
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/utils/subclass_with_meta.py#L9-L12
30
[ 0, 1, 2 ]
75
[ 3 ]
25
false
86.666667
4
2
75
0
def __str__(cls): if cls._meta: return cls._meta.name return cls.__name__
20,670
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/utils/subclass_with_meta.py
SubclassWithMeta_Meta.__repr__
(cls)
return f"<{cls.__name__} meta={repr(cls._meta)}>"
14
15
def __repr__(cls): return f"<{cls.__name__} meta={repr(cls._meta)}>"
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/utils/subclass_with_meta.py#L14-L15
30
[ 0 ]
50
[ 1 ]
50
false
86.666667
2
1
50
0
def __repr__(cls): return f"<{cls.__name__} meta={repr(cls._meta)}>"
20,671
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/utils/subclass_with_meta.py
SubclassWithMeta.__init_subclass__
(cls, **meta_options)
This method just terminates the super() chain
This method just terminates the super() chain
21
46
def __init_subclass__(cls, **meta_options): """This method just terminates the super() chain""" _Meta = getattr(cls, "Meta", None) _meta_props = {} if _Meta: if isinstance(_Meta, dict): _meta_props = _Meta elif isclass(_Meta): _meta_props = props(_Meta) else: raise Exception( f"Meta have to be either a class or a dict. Received {_Meta}" ) delattr(cls, "Meta") options = dict(meta_options, **_meta_props) abstract = options.pop("abstract", False) if abstract: assert not options, ( "Abstract types can only contain the abstract attribute. " f"Received: abstract, {', '.join(options)}" ) else: super_class = super(cls, cls) if hasattr(super_class, "__init_subclass_with_meta__"): super_class.__init_subclass_with_meta__(**options)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/utils/subclass_with_meta.py#L21-L46
30
[ 0, 1, 2, 3, 4, 5, 7, 8, 9, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ]
88.461538
[ 6, 10 ]
7.692308
false
86.666667
26
7
92.307692
1
def __init_subclass__(cls, **meta_options): _Meta = getattr(cls, "Meta", None) _meta_props = {} if _Meta: if isinstance(_Meta, dict): _meta_props = _Meta elif isclass(_Meta): _meta_props = props(_Meta) else: raise Exception( f"Meta have to be either a class or a dict. Received {_Meta}" ) delattr(cls, "Meta") options = dict(meta_options, **_meta_props) abstract = options.pop("abstract", False) if abstract: assert not options, ( "Abstract types can only contain the abstract attribute. " f"Received: abstract, {', '.join(options)}" ) else: super_class = super(cls, cls) if hasattr(super_class, "__init_subclass_with_meta__"): super_class.__init_subclass_with_meta__(**options)
20,672
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/utils/subclass_with_meta.py
SubclassWithMeta.__init_subclass_with_meta__
(cls, **meta_options)
This method just terminates the super() chain
This method just terminates the super() chain
49
50
def __init_subclass_with_meta__(cls, **meta_options): """This method just terminates the super() chain"""
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/utils/subclass_with_meta.py#L49-L50
30
[ 0, 1 ]
100
[]
0
true
86.666667
2
1
100
1
def __init_subclass_with_meta__(cls, **meta_options):
20,673
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/id_type.py
BaseGlobalIDType.resolve_global_id
(cls, info, global_id)
17
19
def resolve_global_id(cls, info, global_id): # return _type, _id raise NotImplementedError
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/id_type.py#L17-L19
30
[ 0, 1 ]
66.666667
[ 2 ]
33.333333
false
63.636364
3
1
66.666667
0
def resolve_global_id(cls, info, global_id): # return _type, _id raise NotImplementedError
20,718
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/id_type.py
BaseGlobalIDType.to_global_id
(cls, _type, _id)
22
24
def to_global_id(cls, _type, _id): # return _id raise NotImplementedError
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/id_type.py#L22-L24
30
[ 0, 1 ]
66.666667
[ 2 ]
33.333333
false
63.636364
3
1
66.666667
0
def to_global_id(cls, _type, _id): # return _id raise NotImplementedError
20,719
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/id_type.py
DefaultGlobalIDType.resolve_global_id
(cls, info, global_id)
35
46
def resolve_global_id(cls, info, global_id): try: _type, _id = from_global_id(global_id) if not _type: raise ValueError("Invalid Global ID") return _type, _id except Exception as e: raise Exception( f'Unable to parse global ID "{global_id}". ' 'Make sure it is a base64 encoded string in the format: "TypeName:id". ' f"Exception message: {e}" )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/id_type.py#L35-L46
30
[ 0 ]
8.333333
[ 1, 2, 3, 4, 5, 6, 7 ]
58.333333
false
63.636364
12
3
41.666667
0
def resolve_global_id(cls, info, global_id): try: _type, _id = from_global_id(global_id) if not _type: raise ValueError("Invalid Global ID") return _type, _id except Exception as e: raise Exception( f'Unable to parse global ID "{global_id}". ' 'Make sure it is a base64 encoded string in the format: "TypeName:id". ' f"Exception message: {e}" )
20,720
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/id_type.py
DefaultGlobalIDType.to_global_id
(cls, _type, _id)
return to_global_id(_type, _id)
49
50
def to_global_id(cls, _type, _id): return to_global_id(_type, _id)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/id_type.py#L49-L50
30
[ 0 ]
50
[ 1 ]
50
false
63.636364
2
1
50
0
def to_global_id(cls, _type, _id): return to_global_id(_type, _id)
20,721
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/id_type.py
SimpleGlobalIDType.resolve_global_id
(cls, info, global_id)
return _type, global_id
63
65
def resolve_global_id(cls, info, global_id): _type = info.return_type.graphene_type._meta.name return _type, global_id
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/id_type.py#L63-L65
30
[ 0 ]
33.333333
[ 1, 2 ]
66.666667
false
63.636364
3
1
33.333333
0
def resolve_global_id(cls, info, global_id): _type = info.return_type.graphene_type._meta.name return _type, global_id
20,722
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/id_type.py
SimpleGlobalIDType.to_global_id
(cls, _type, _id)
return _id
68
69
def to_global_id(cls, _type, _id): return _id
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/id_type.py#L68-L69
30
[ 0 ]
50
[ 1 ]
50
false
63.636364
2
1
50
0
def to_global_id(cls, _type, _id): return _id
20,723
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/id_type.py
UUIDGlobalIDType.resolve_global_id
(cls, info, global_id)
return _type, global_id
81
83
def resolve_global_id(cls, info, global_id): _type = info.return_type.graphene_type._meta.name return _type, global_id
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/id_type.py#L81-L83
30
[ 0 ]
33.333333
[ 1, 2 ]
66.666667
false
63.636364
3
1
33.333333
0
def resolve_global_id(cls, info, global_id): _type = info.return_type.graphene_type._meta.name return _type, global_id
20,724
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/id_type.py
UUIDGlobalIDType.to_global_id
(cls, _type, _id)
return _id
86
87
def to_global_id(cls, _type, _id): return _id
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/id_type.py#L86-L87
30
[ 0 ]
50
[ 1 ]
50
false
63.636364
2
1
50
0
def to_global_id(cls, _type, _id): return _id
20,725
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/mutation.py
ClientIDMutation.__init_subclass_with_meta__
( cls, output=None, input_fields=None, arguments=None, name=None, **options )
13
52
def __init_subclass_with_meta__( cls, output=None, input_fields=None, arguments=None, name=None, **options ): input_class = getattr(cls, "Input", None) base_name = re.sub("Payload$", "", name or cls.__name__) assert not output, "Can't specify any output" assert not arguments, "Can't specify any arguments" bases = (InputObjectType,) if input_class: bases += (input_class,) if not input_fields: input_fields = {} cls.Input = type( f"{base_name}Input", bases, dict(input_fields, client_mutation_id=String(name="clientMutationId")), ) arguments = dict( input=cls.Input(required=True) # 'client_mutation_id': String(name='clientMutationId') ) mutate_and_get_payload = getattr(cls, "mutate_and_get_payload", None) if cls.mutate and cls.mutate.__func__ == ClientIDMutation.mutate.__func__: assert mutate_and_get_payload, ( f"{name or cls.__name__}.mutate_and_get_payload method is required" " in a ClientIDMutation." ) if not name: name = f"{base_name}Payload" super(ClientIDMutation, cls).__init_subclass_with_meta__( output=None, arguments=arguments, name=name, **options ) cls._meta.fields["client_mutation_id"] = Field(String, name="clientMutationId")
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/mutation.py#L13-L52
30
[ 0 ]
2.5
[ 3, 4, 6, 7, 9, 10, 11, 13, 14, 16, 22, 26, 27, 28, 33, 34, 36, 39 ]
45
false
29.72973
40
11
55
0
def __init_subclass_with_meta__( cls, output=None, input_fields=None, arguments=None, name=None, **options ): input_class = getattr(cls, "Input", None) base_name = re.sub("Payload$", "", name or cls.__name__) assert not output, "Can't specify any output" assert not arguments, "Can't specify any arguments" bases = (InputObjectType,) if input_class: bases += (input_class,) if not input_fields: input_fields = {} cls.Input = type( f"{base_name}Input", bases, dict(input_fields, client_mutation_id=String(name="clientMutationId")), ) arguments = dict( input=cls.Input(required=True) # 'client_mutation_id': String(name='clientMutationId') ) mutate_and_get_payload = getattr(cls, "mutate_and_get_payload", None) if cls.mutate and cls.mutate.__func__ == ClientIDMutation.mutate.__func__: assert mutate_and_get_payload, ( f"{name or cls.__name__}.mutate_and_get_payload method is required" " in a ClientIDMutation." ) if not name: name = f"{base_name}Payload" super(ClientIDMutation, cls).__init_subclass_with_meta__( output=None, arguments=arguments, name=name, **options ) cls._meta.fields["client_mutation_id"] = Field(String, name="clientMutationId")
20,726
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/mutation.py
ClientIDMutation.mutate
(cls, root, info, input)
return maybe_thenable(result, on_resolve)
55
66
def mutate(cls, root, info, input): def on_resolve(payload): try: payload.client_mutation_id = input.get("client_mutation_id") except Exception: raise Exception( f"Cannot set client_mutation_id in the payload object {repr(payload)}" ) return payload result = cls.mutate_and_get_payload(root, info, **input) return maybe_thenable(result, on_resolve)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/mutation.py#L55-L66
30
[ 0 ]
8.333333
[ 1, 2, 3, 4, 5, 8, 10, 11 ]
66.666667
false
29.72973
12
3
33.333333
0
def mutate(cls, root, info, input): def on_resolve(payload): try: payload.client_mutation_id = input.get("client_mutation_id") except Exception: raise Exception( f"Cannot set client_mutation_id in the payload object {repr(payload)}" ) return payload result = cls.mutate_and_get_payload(root, info, **input) return maybe_thenable(result, on_resolve)
20,727
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
is_node
(objecttype)
return any(issubclass(i, Node) for i in objecttype._meta.interfaces)
Check if the given objecttype has Node as an interface
Check if the given objecttype has Node as an interface
10
20
def is_node(objecttype): """ Check if the given objecttype has Node as an interface """ if not isclass(objecttype): return False if not issubclass(objecttype, ObjectType): return False return any(issubclass(i, Node) for i in objecttype._meta.interfaces)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L10-L20
30
[ 0, 1, 2, 3, 4, 6, 7, 8, 9 ]
81.818182
[ 5, 10 ]
18.181818
false
60
11
3
81.818182
1
def is_node(objecttype): if not isclass(objecttype): return False if not issubclass(objecttype, ObjectType): return False return any(issubclass(i, Node) for i in objecttype._meta.interfaces)
20,728
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
GlobalID.__init__
( self, node=None, parent_type=None, required=True, global_id_type=DefaultGlobalIDType, *args, **kwargs, )
24
37
def __init__( self, node=None, parent_type=None, required=True, global_id_type=DefaultGlobalIDType, *args, **kwargs, ): super(GlobalID, self).__init__( global_id_type.graphene_type, required=required, *args, **kwargs ) self.node = node or Node self.parent_type_name = parent_type._meta.name if parent_type else None
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L24-L37
30
[ 0, 9, 12, 13 ]
28.571429
[]
0
false
60
14
2
100
0
def __init__( self, node=None, parent_type=None, required=True, global_id_type=DefaultGlobalIDType, *args, **kwargs, ): super(GlobalID, self).__init__( global_id_type.graphene_type, required=required, *args, **kwargs ) self.node = node or Node self.parent_type_name = parent_type._meta.name if parent_type else None
20,729
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
GlobalID.id_resolver
(parent_resolver, node, root, info, parent_type_name=None, **args)
return node.to_global_id(parent_type_name, type_id)
40
43
def id_resolver(parent_resolver, node, root, info, parent_type_name=None, **args): type_id = parent_resolver(root, info, **args) parent_type_name = parent_type_name or info.parent_type.name return node.to_global_id(parent_type_name, type_id)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L40-L43
30
[ 0 ]
25
[ 1, 2, 3 ]
75
false
60
4
2
25
0
def id_resolver(parent_resolver, node, root, info, parent_type_name=None, **args): type_id = parent_resolver(root, info, **args) parent_type_name = parent_type_name or info.parent_type.name return node.to_global_id(parent_type_name, type_id)
20,730
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
GlobalID.wrap_resolve
(self, parent_resolver)
return partial( self.id_resolver, parent_resolver, self.node, parent_type_name=self.parent_type_name, )
45
51
def wrap_resolve(self, parent_resolver): return partial( self.id_resolver, parent_resolver, self.node, parent_type_name=self.parent_type_name, )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L45-L51
30
[ 0 ]
14.285714
[ 1 ]
14.285714
false
60
7
1
85.714286
0
def wrap_resolve(self, parent_resolver): return partial( self.id_resolver, parent_resolver, self.node, parent_type_name=self.parent_type_name, )
20,731
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
NodeField.__init__
(self, node, type_=False, **kwargs)
55
68
def __init__(self, node, type_=False, **kwargs): assert issubclass(node, Node), "NodeField can only operate in Nodes" self.node_type = node self.field_type = type_ global_id_type = node._meta.global_id_type super(NodeField, self).__init__( # If we don't specify a type, the field type will be the node interface type_ or node, id=global_id_type.graphene_type( required=True, description="The ID of the object" ), **kwargs, )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L55-L68
30
[ 0 ]
7.142857
[ 1, 2, 3, 4, 6 ]
35.714286
false
60
14
3
64.285714
0
def __init__(self, node, type_=False, **kwargs): assert issubclass(node, Node), "NodeField can only operate in Nodes" self.node_type = node self.field_type = type_ global_id_type = node._meta.global_id_type super(NodeField, self).__init__( # If we don't specify a type, the field type will be the node interface type_ or node, id=global_id_type.graphene_type( required=True, description="The ID of the object" ), **kwargs, )
20,732
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
NodeField.wrap_resolve
(self, parent_resolver)
return partial(self.node_type.node_resolver, get_type(self.field_type))
70
71
def wrap_resolve(self, parent_resolver): return partial(self.node_type.node_resolver, get_type(self.field_type))
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L70-L71
30
[ 0 ]
50
[ 1 ]
50
false
60
2
1
50
0
def wrap_resolve(self, parent_resolver): return partial(self.node_type.node_resolver, get_type(self.field_type))
20,733
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
AbstractNode.__init_subclass_with_meta__
(cls, global_id_type=DefaultGlobalIDType, **options)
79
90
def __init_subclass_with_meta__(cls, global_id_type=DefaultGlobalIDType, **options): assert issubclass( global_id_type, BaseGlobalIDType ), "Custom ID type need to be implemented as a subclass of BaseGlobalIDType." _meta = InterfaceOptions(cls) _meta.global_id_type = global_id_type _meta.fields = { "id": GlobalID( cls, global_id_type=global_id_type, description="The ID of the object" ) } super(AbstractNode, cls).__init_subclass_with_meta__(_meta=_meta, **options)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L79-L90
30
[ 0, 1, 4, 5, 6, 11 ]
50
[]
0
false
60
12
2
100
0
def __init_subclass_with_meta__(cls, global_id_type=DefaultGlobalIDType, **options): assert issubclass( global_id_type, BaseGlobalIDType ), "Custom ID type need to be implemented as a subclass of BaseGlobalIDType." _meta = InterfaceOptions(cls) _meta.global_id_type = global_id_type _meta.fields = { "id": GlobalID( cls, global_id_type=global_id_type, description="The ID of the object" ) } super(AbstractNode, cls).__init_subclass_with_meta__(_meta=_meta, **options)
20,734
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
AbstractNode.resolve_global_id
(cls, info, global_id)
return cls._meta.global_id_type.resolve_global_id(info, global_id)
93
94
def resolve_global_id(cls, info, global_id): return cls._meta.global_id_type.resolve_global_id(info, global_id)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L93-L94
30
[ 0 ]
50
[ 1 ]
50
false
60
2
1
50
0
def resolve_global_id(cls, info, global_id): return cls._meta.global_id_type.resolve_global_id(info, global_id)
20,735
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
Node.Field
(cls, *args, **kwargs)
return NodeField(cls, *args, **kwargs)
101
102
def Field(cls, *args, **kwargs): # noqa: N802 return NodeField(cls, *args, **kwargs)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L101-L102
30
[ 0 ]
50
[ 1 ]
50
false
60
2
1
50
0
def Field(cls, *args, **kwargs): # noqa: N802 return NodeField(cls, *args, **kwargs)
20,736
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
Node.node_resolver
(cls, only_type, root, info, id)
return cls.get_node_from_global_id(info, id, only_type=only_type)
105
106
def node_resolver(cls, only_type, root, info, id): return cls.get_node_from_global_id(info, id, only_type=only_type)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L105-L106
30
[ 0 ]
50
[ 1 ]
50
false
60
2
1
50
0
def node_resolver(cls, only_type, root, info, id): return cls.get_node_from_global_id(info, id, only_type=only_type)
20,737
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
Node.get_node_from_global_id
(cls, info, global_id, only_type=None)
109
131
def get_node_from_global_id(cls, info, global_id, only_type=None): _type, _id = cls.resolve_global_id(info, global_id) graphene_type = info.schema.get_type(_type) if graphene_type is None: raise Exception(f'Relay Node "{_type}" not found in schema') graphene_type = graphene_type.graphene_type if only_type: assert ( graphene_type == only_type ), f"Must receive a {only_type._meta.name} id." # We make sure the ObjectType implements the "Node" interface if cls not in graphene_type._meta.interfaces: raise Exception( f'ObjectType "{_type}" does not implement the "{cls}" interface.' ) get_node = getattr(graphene_type, "get_node", None) if get_node: return get_node(info, _id)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L109-L131
30
[ 0 ]
4.347826
[ 1, 3, 4, 5, 7, 9, 10, 15, 16, 20, 21, 22 ]
52.173913
false
60
23
6
47.826087
0
def get_node_from_global_id(cls, info, global_id, only_type=None): _type, _id = cls.resolve_global_id(info, global_id) graphene_type = info.schema.get_type(_type) if graphene_type is None: raise Exception(f'Relay Node "{_type}" not found in schema') graphene_type = graphene_type.graphene_type if only_type: assert ( graphene_type == only_type ), f"Must receive a {only_type._meta.name} id." # We make sure the ObjectType implements the "Node" interface if cls not in graphene_type._meta.interfaces: raise Exception( f'ObjectType "{_type}" does not implement the "{cls}" interface.' ) get_node = getattr(graphene_type, "get_node", None) if get_node: return get_node(info, _id)
20,738
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/node.py
Node.to_global_id
(cls, type_, id)
return cls._meta.global_id_type.to_global_id(type_, id)
134
135
def to_global_id(cls, type_, id): return cls._meta.global_id_type.to_global_id(type_, id)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/node.py#L134-L135
30
[ 0 ]
50
[ 1 ]
50
false
60
2
1
50
0
def to_global_id(cls, type_, id): return cls._meta.global_id_type.to_global_id(type_, id)
20,739
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/connection.py
page_info_adapter
(startCursor, endCursor, hasPreviousPage, hasNextPage)
return PageInfo( start_cursor=startCursor, end_cursor=endCursor, has_previous_page=hasPreviousPage, has_next_page=hasNextPage, )
Adapter for creating PageInfo instances
Adapter for creating PageInfo instances
45
52
def page_info_adapter(startCursor, endCursor, hasPreviousPage, hasNextPage): """Adapter for creating PageInfo instances""" return PageInfo( start_cursor=startCursor, end_cursor=endCursor, has_previous_page=hasPreviousPage, has_next_page=hasNextPage, )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/connection.py#L45-L52
30
[ 0, 1 ]
25
[ 2 ]
12.5
false
52.325581
8
1
87.5
1
def page_info_adapter(startCursor, endCursor, hasPreviousPage, hasNextPage): return PageInfo( start_cursor=startCursor, end_cursor=endCursor, has_previous_page=hasPreviousPage, has_next_page=hasNextPage, )
20,740
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/connection.py
connection_adapter
(cls, edges, pageInfo)
return cls(edges=edges, page_info=pageInfo)
Adapter for creating Connection instances
Adapter for creating Connection instances
114
116
def connection_adapter(cls, edges, pageInfo): """Adapter for creating Connection instances""" return cls(edges=edges, page_info=pageInfo)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/connection.py#L114-L116
30
[ 0, 1 ]
66.666667
[ 2 ]
33.333333
false
52.325581
3
1
66.666667
1
def connection_adapter(cls, edges, pageInfo): return cls(edges=edges, page_info=pageInfo)
20,741
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/connection.py
Connection.__init_subclass_with_meta__
(cls, node=None, name=None, **options)
return super(Connection, cls).__init_subclass_with_meta__( _meta=_meta, **options )
64
110
def __init_subclass_with_meta__(cls, node=None, name=None, **options): _meta = ConnectionOptions(cls) assert node, f"You have to provide a node in {cls.__name__}.Meta" assert isinstance(node, NonNull) or issubclass( node, (Scalar, Enum, ObjectType, Interface, Union, NonNull) ), f'Received incompatible node "{node}" for Connection {cls.__name__}.' base_name = re.sub("Connection$", "", name or cls.__name__) or node._meta.name if not name: name = f"{base_name}Connection" edge_class = getattr(cls, "Edge", None) _node = node class EdgeBase: node = Field(_node, description="The item at the end of the edge") cursor = String(required=True, description="A cursor for use in pagination") class EdgeMeta: description = f"A Relay edge containing a `{base_name}` and its cursor." edge_name = f"{base_name}Edge" if edge_class: edge_bases = (edge_class, EdgeBase, ObjectType) else: edge_bases = (EdgeBase, ObjectType) edge = type(edge_name, edge_bases, {"Meta": EdgeMeta}) cls.Edge = edge options["name"] = name _meta.node = node _meta.fields = { "page_info": Field( PageInfo, name="pageInfo", required=True, description="Pagination data for this connection.", ), "edges": Field( NonNull(List(edge)), description="Contains the nodes in this connection.", ), } return super(Connection, cls).__init_subclass_with_meta__( _meta=_meta, **options )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/connection.py#L64-L110
30
[ 0 ]
2.12766
[ 1, 2, 3, 7, 8, 9, 11, 12, 14, 15, 16, 18, 19, 21, 22, 23, 25, 27, 28, 30, 31, 32, 44 ]
48.93617
false
52.325581
47
8
51.06383
0
def __init_subclass_with_meta__(cls, node=None, name=None, **options): _meta = ConnectionOptions(cls) assert node, f"You have to provide a node in {cls.__name__}.Meta" assert isinstance(node, NonNull) or issubclass( node, (Scalar, Enum, ObjectType, Interface, Union, NonNull) ), f'Received incompatible node "{node}" for Connection {cls.__name__}.' base_name = re.sub("Connection$", "", name or cls.__name__) or node._meta.name if not name: name = f"{base_name}Connection" edge_class = getattr(cls, "Edge", None) _node = node class EdgeBase: node = Field(_node, description="The item at the end of the edge") cursor = String(required=True, description="A cursor for use in pagination") class EdgeMeta: description = f"A Relay edge containing a `{base_name}` and its cursor." edge_name = f"{base_name}Edge" if edge_class: edge_bases = (edge_class, EdgeBase, ObjectType) else: edge_bases = (EdgeBase, ObjectType) edge = type(edge_name, edge_bases, {"Meta": EdgeMeta}) cls.Edge = edge options["name"] = name _meta.node = node _meta.fields = { "page_info": Field( PageInfo, name="pageInfo", required=True, description="Pagination data for this connection.", ), "edges": Field( NonNull(List(edge)), description="Contains the nodes in this connection.", ), } return super(Connection, cls).__init_subclass_with_meta__( _meta=_meta, **options )
20,742
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/connection.py
IterableConnectionField.__init__
(self, type_, *args, **kwargs)
120
125
def __init__(self, type_, *args, **kwargs): kwargs.setdefault("before", String()) kwargs.setdefault("after", String()) kwargs.setdefault("first", Int()) kwargs.setdefault("last", Int()) super(IterableConnectionField, self).__init__(type_, *args, **kwargs)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/connection.py#L120-L125
30
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
52.325581
6
1
100
0
def __init__(self, type_, *args, **kwargs): kwargs.setdefault("before", String()) kwargs.setdefault("after", String()) kwargs.setdefault("first", Int()) kwargs.setdefault("last", Int()) super(IterableConnectionField, self).__init__(type_, *args, **kwargs)
20,743
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/connection.py
IterableConnectionField.type
(self)
return type_
128
143
def type(self): type_ = super(IterableConnectionField, self).type connection_type = type_ if isinstance(type_, NonNull): connection_type = type_.of_type if is_node(connection_type): raise Exception( "ConnectionFields now need a explicit ConnectionType for Nodes.\n" "Read more: https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#node-connections" ) assert issubclass( connection_type, Connection ), f'{self.__class__.__name__} type has to be a subclass of Connection. Received "{connection_type}".' return type_
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/connection.py#L128-L143
30
[ 0, 1, 2, 3, 5, 6, 11, 12 ]
50
[ 4, 7, 15 ]
18.75
false
52.325581
16
4
81.25
0
def type(self): type_ = super(IterableConnectionField, self).type connection_type = type_ if isinstance(type_, NonNull): connection_type = type_.of_type if is_node(connection_type): raise Exception( "ConnectionFields now need a explicit ConnectionType for Nodes.\n" "Read more: https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#node-connections" ) assert issubclass( connection_type, Connection ), f'{self.__class__.__name__} type has to be a subclass of Connection. Received "{connection_type}".' return type_
20,744
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/connection.py
IterableConnectionField.resolve_connection
(cls, connection_type, args, resolved)
return connection
146
162
def resolve_connection(cls, connection_type, args, resolved): if isinstance(resolved, connection_type): return resolved assert isinstance(resolved, Iterable), ( f"Resolved value from the connection field has to be an iterable or instance of {connection_type}. " f'Received "{resolved}"' ) connection = connection_from_array( resolved, args, connection_type=partial(connection_adapter, connection_type), edge_type=connection_type.Edge, page_info_type=page_info_adapter, ) connection.iterable = resolved return connection
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/connection.py#L146-L162
30
[ 0 ]
5.882353
[ 1, 2, 4, 8, 15, 16 ]
35.294118
false
52.325581
17
3
64.705882
0
def resolve_connection(cls, connection_type, args, resolved): if isinstance(resolved, connection_type): return resolved assert isinstance(resolved, Iterable), ( f"Resolved value from the connection field has to be an iterable or instance of {connection_type}. " f'Received "{resolved}"' ) connection = connection_from_array( resolved, args, connection_type=partial(connection_adapter, connection_type), edge_type=connection_type.Edge, page_info_type=page_info_adapter, ) connection.iterable = resolved return connection
20,745
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/connection.py
IterableConnectionField.connection_resolver
(cls, resolver, connection_type, root, info, **args)
return maybe_thenable(resolved, on_resolve)
165
172
def connection_resolver(cls, resolver, connection_type, root, info, **args): resolved = resolver(root, info, **args) if isinstance(connection_type, NonNull): connection_type = connection_type.of_type on_resolve = partial(cls.resolve_connection, connection_type, args) return maybe_thenable(resolved, on_resolve)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/connection.py#L165-L172
30
[ 0 ]
12.5
[ 1, 3, 4, 6, 7 ]
62.5
false
52.325581
8
2
37.5
0
def connection_resolver(cls, resolver, connection_type, root, info, **args): resolved = resolver(root, info, **args) if isinstance(connection_type, NonNull): connection_type = connection_type.of_type on_resolve = partial(cls.resolve_connection, connection_type, args) return maybe_thenable(resolved, on_resolve)
20,746
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/relay/connection.py
IterableConnectionField.wrap_resolve
(self, parent_resolver)
return partial(self.connection_resolver, resolver, self.type)
174
176
def wrap_resolve(self, parent_resolver): resolver = super(IterableConnectionField, self).wrap_resolve(parent_resolver) return partial(self.connection_resolver, resolver, self.type)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/relay/connection.py#L174-L176
30
[ 0 ]
33.333333
[ 1, 2 ]
66.666667
false
52.325581
3
1
33.333333
0
def wrap_resolve(self, parent_resolver): resolver = super(IterableConnectionField, self).wrap_resolve(parent_resolver) return partial(self.connection_resolver, resolver, self.type)
20,747
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/resolver.py
attr_resolver
(attname, default_value, root, info, **args)
return getattr(root, attname, default_value)
1
2
def attr_resolver(attname, default_value, root, info, **args): return getattr(root, attname, default_value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/resolver.py#L1-L2
30
[ 0, 1 ]
100
[]
0
true
76.923077
2
1
100
0
def attr_resolver(attname, default_value, root, info, **args): return getattr(root, attname, default_value)
20,748
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/resolver.py
dict_resolver
(attname, default_value, root, info, **args)
return root.get(attname, default_value)
5
6
def dict_resolver(attname, default_value, root, info, **args): return root.get(attname, default_value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/resolver.py#L5-L6
30
[ 0 ]
50
[ 1 ]
50
false
76.923077
2
1
50
0
def dict_resolver(attname, default_value, root, info, **args): return root.get(attname, default_value)
20,749
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/resolver.py
dict_or_attr_resolver
(attname, default_value, root, info, **args)
return resolver(attname, default_value, root, info, **args)
9
11
def dict_or_attr_resolver(attname, default_value, root, info, **args): resolver = dict_resolver if isinstance(root, dict) else attr_resolver return resolver(attname, default_value, root, info, **args)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/resolver.py#L9-L11
30
[ 0, 1, 2 ]
100
[]
0
true
76.923077
3
1
100
0
def dict_or_attr_resolver(attname, default_value, root, info, **args): resolver = dict_resolver if isinstance(root, dict) else attr_resolver return resolver(attname, default_value, root, info, **args)
20,750
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/resolver.py
set_default_resolver
(resolver)
17
20
def set_default_resolver(resolver): global default_resolver assert callable(resolver), "Received non-callable resolver." default_resolver = resolver
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/resolver.py#L17-L20
30
[ 0 ]
25
[ 2, 3 ]
50
false
76.923077
4
2
50
0
def set_default_resolver(resolver): global default_resolver assert callable(resolver), "Received non-callable resolver." default_resolver = resolver
20,751
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/resolver.py
get_default_resolver
()
return default_resolver
23
24
def get_default_resolver(): return default_resolver
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/resolver.py#L23-L24
30
[ 0, 1 ]
100
[]
0
true
76.923077
2
1
100
0
def get_default_resolver(): return default_resolver
20,752
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/union.py
Union.__init_subclass_with_meta__
(cls, types=None, **options)
53
60
def __init_subclass_with_meta__(cls, types=None, **options): assert ( isinstance(types, (list, tuple)) and len(types) > 0 ), f"Must provide types for Union {cls.__name__}." _meta = UnionOptions(cls) _meta.types = types super(Union, cls).__init_subclass_with_meta__(_meta=_meta, **options)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/union.py#L53-L60
30
[ 0, 1, 4, 5, 6, 7 ]
75
[]
0
false
86.956522
8
3
100
0
def __init_subclass_with_meta__(cls, types=None, **options): assert ( isinstance(types, (list, tuple)) and len(types) > 0 ), f"Must provide types for Union {cls.__name__}." _meta = UnionOptions(cls) _meta.types = types super(Union, cls).__init_subclass_with_meta__(_meta=_meta, **options)
20,753
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/union.py
Union.get_type
(cls)
return cls
This function is called when the unmounted type (Union instance) is mounted (as a Field, InputField or Argument)
This function is called when the unmounted type (Union instance) is mounted (as a Field, InputField or Argument)
63
68
def get_type(cls): """ This function is called when the unmounted type (Union instance) is mounted (as a Field, InputField or Argument) """ return cls
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/union.py#L63-L68
30
[ 0, 1, 2, 3, 4 ]
83.333333
[ 5 ]
16.666667
false
86.956522
6
1
83.333333
2
def get_type(cls): return cls
20,754
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/union.py
Union.resolve_type
(cls, instance, info)
71
75
def resolve_type(cls, instance, info): from .objecttype import ObjectType # NOQA if isinstance(instance, ObjectType): return type(instance)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/union.py#L71-L75
30
[ 0, 1, 2, 3, 4 ]
100
[]
0
true
86.956522
5
2
100
0
def resolve_type(cls, instance, info): from .objecttype import ObjectType # NOQA if isinstance(instance, ObjectType): return type(instance)
20,755
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
assert_valid_root_type
(type_)
59
66
def assert_valid_root_type(type_): if type_ is None: return is_graphene_objecttype = inspect.isclass(type_) and issubclass(type_, ObjectType) is_graphql_objecttype = isinstance(type_, GraphQLObjectType) assert ( is_graphene_objecttype or is_graphql_objecttype ), f"Type {type_} is not a valid ObjectType."
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L59-L66
30
[ 0, 1, 2, 3, 4, 5 ]
75
[]
0
false
67.083333
8
5
100
0
def assert_valid_root_type(type_): if type_ is None: return is_graphene_objecttype = inspect.isclass(type_) and issubclass(type_, ObjectType) is_graphql_objecttype = isinstance(type_, GraphQLObjectType) assert ( is_graphene_objecttype or is_graphql_objecttype ), f"Type {type_} is not a valid ObjectType."
20,756
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
is_graphene_type
(type_)
69
75
def is_graphene_type(type_): if isinstance(type_, (List, NonNull)): return True if inspect.isclass(type_) and issubclass( type_, (ObjectType, InputObjectType, Scalar, Interface, Union, Enum) ): return True
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L69-L75
30
[ 0 ]
14.285714
[ 1, 2, 3, 6 ]
57.142857
false
67.083333
7
4
42.857143
0
def is_graphene_type(type_): if isinstance(type_, (List, NonNull)): return True if inspect.isclass(type_) and issubclass( type_, (ObjectType, InputObjectType, Scalar, Interface, Union, Enum) ): return True
20,757
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
is_type_of_from_possible_types
(possible_types, root, _info)
return isinstance(root, possible_types)
78
79
def is_type_of_from_possible_types(possible_types, root, _info): return isinstance(root, possible_types)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L78-L79
30
[ 0 ]
50
[ 1 ]
50
false
67.083333
2
1
50
0
def is_type_of_from_possible_types(possible_types, root, _info): return isinstance(root, possible_types)
20,758
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
identity_resolve
(root, info, **arguments)
return root
83
84
def identity_resolve(root, info, **arguments): return root
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L83-L84
30
[ 0 ]
50
[ 1 ]
50
false
67.083333
2
1
50
0
def identity_resolve(root, info, **arguments): return root
20,759
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
normalize_execute_kwargs
(kwargs)
return kwargs
Replace alias names in keyword arguments for graphql()
Replace alias names in keyword arguments for graphql()
525
535
def normalize_execute_kwargs(kwargs): """Replace alias names in keyword arguments for graphql()""" if "root" in kwargs and "root_value" not in kwargs: kwargs["root_value"] = kwargs.pop("root") if "context" in kwargs and "context_value" not in kwargs: kwargs["context_value"] = kwargs.pop("context") if "variables" in kwargs and "variable_values" not in kwargs: kwargs["variable_values"] = kwargs.pop("variables") if "operation" in kwargs and "operation_name" not in kwargs: kwargs["operation_name"] = kwargs.pop("operation") return kwargs
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L525-L535
30
[ 0, 1, 2, 4, 6, 7, 8, 10 ]
72.727273
[ 3, 5, 9 ]
27.272727
false
67.083333
11
9
72.727273
1
def normalize_execute_kwargs(kwargs): if "root" in kwargs and "root_value" not in kwargs: kwargs["root_value"] = kwargs.pop("root") if "context" in kwargs and "context_value" not in kwargs: kwargs["context_value"] = kwargs.pop("context") if "variables" in kwargs and "variable_values" not in kwargs: kwargs["variable_values"] = kwargs.pop("variables") if "operation" in kwargs and "operation_name" not in kwargs: kwargs["operation_name"] = kwargs.pop("operation") return kwargs
20,760
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.__init__
( self, query=None, mutation=None, subscription=None, types=None, auto_camelcase=True, )
88
112
def __init__( self, query=None, mutation=None, subscription=None, types=None, auto_camelcase=True, ): assert_valid_root_type(query) assert_valid_root_type(mutation) assert_valid_root_type(subscription) if types is None: types = [] for type_ in types: assert is_graphene_type(type_) self.auto_camelcase = auto_camelcase create_graphql_type = self.add_type self.query = create_graphql_type(query) if query else None self.mutation = create_graphql_type(mutation) if mutation else None self.subscription = create_graphql_type(subscription) if subscription else None self.types = [create_graphql_type(graphene_type) for graphene_type in types]
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L88-L112
30
[ 0, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 ]
68
[ 14 ]
4
false
67.083333
25
5
96
0
def __init__( self, query=None, mutation=None, subscription=None, types=None, auto_camelcase=True, ): assert_valid_root_type(query) assert_valid_root_type(mutation) assert_valid_root_type(subscription) if types is None: types = [] for type_ in types: assert is_graphene_type(type_) self.auto_camelcase = auto_camelcase create_graphql_type = self.add_type self.query = create_graphql_type(query) if query else None self.mutation = create_graphql_type(mutation) if mutation else None self.subscription = create_graphql_type(subscription) if subscription else None self.types = [create_graphql_type(graphene_type) for graphene_type in types]
20,761
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.add_type
(self, graphene_type)
return graphql_type
114
143
def add_type(self, graphene_type): if inspect.isfunction(graphene_type): graphene_type = graphene_type() if isinstance(graphene_type, List): return GraphQLList(self.add_type(graphene_type.of_type)) if isinstance(graphene_type, NonNull): return GraphQLNonNull(self.add_type(graphene_type.of_type)) try: name = graphene_type._meta.name except AttributeError: raise TypeError(f"Expected Graphene type, but received: {graphene_type}.") graphql_type = self.get(name) if graphql_type: return graphql_type if issubclass(graphene_type, ObjectType): graphql_type = self.create_objecttype(graphene_type) elif issubclass(graphene_type, InputObjectType): graphql_type = self.create_inputobjecttype(graphene_type) elif issubclass(graphene_type, Interface): graphql_type = self.create_interface(graphene_type) elif issubclass(graphene_type, Scalar): graphql_type = self.create_scalar(graphene_type) elif issubclass(graphene_type, Enum): graphql_type = self.create_enum(graphene_type) elif issubclass(graphene_type, Union): graphql_type = self.construct_union(graphene_type) else: raise TypeError(f"Expected Graphene type, but received: {graphene_type}.") self[name] = graphql_type return graphql_type
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L114-L143
30
[ 0, 1, 3, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 24, 25, 28, 29 ]
73.333333
[ 2, 4, 9, 10, 19, 23, 27 ]
23.333333
false
67.083333
30
12
76.666667
0
def add_type(self, graphene_type): if inspect.isfunction(graphene_type): graphene_type = graphene_type() if isinstance(graphene_type, List): return GraphQLList(self.add_type(graphene_type.of_type)) if isinstance(graphene_type, NonNull): return GraphQLNonNull(self.add_type(graphene_type.of_type)) try: name = graphene_type._meta.name except AttributeError: raise TypeError(f"Expected Graphene type, but received: {graphene_type}.") graphql_type = self.get(name) if graphql_type: return graphql_type if issubclass(graphene_type, ObjectType): graphql_type = self.create_objecttype(graphene_type) elif issubclass(graphene_type, InputObjectType): graphql_type = self.create_inputobjecttype(graphene_type) elif issubclass(graphene_type, Interface): graphql_type = self.create_interface(graphene_type) elif issubclass(graphene_type, Scalar): graphql_type = self.create_scalar(graphene_type) elif issubclass(graphene_type, Enum): graphql_type = self.create_enum(graphene_type) elif issubclass(graphene_type, Union): graphql_type = self.construct_union(graphene_type) else: raise TypeError(f"Expected Graphene type, but received: {graphene_type}.") self[name] = graphql_type return graphql_type
20,762
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.create_scalar
(graphene_type)
return GrapheneScalarType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, serialize=getattr(graphene_type, "serialize", None), parse_value=getattr(graphene_type, "parse_value", None), parse_literal=getattr(graphene_type, "parse_literal", None), )
146
166
def create_scalar(graphene_type): # We have a mapping to the original GraphQL types # so there are no collisions. _scalars = { String: GraphQLString, Int: GraphQLInt, Float: GraphQLFloat, Boolean: GraphQLBoolean, ID: GraphQLID, } if graphene_type in _scalars: return _scalars[graphene_type] return GrapheneScalarType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, serialize=getattr(graphene_type, "serialize", None), parse_value=getattr(graphene_type, "parse_value", None), parse_literal=getattr(graphene_type, "parse_literal", None), )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L146-L166
30
[ 0, 1, 2, 3, 10, 11, 12, 13 ]
38.095238
[]
0
false
67.083333
21
2
100
0
def create_scalar(graphene_type): # We have a mapping to the original GraphQL types # so there are no collisions. _scalars = { String: GraphQLString, Int: GraphQLInt, Float: GraphQLFloat, Boolean: GraphQLBoolean, ID: GraphQLID, } if graphene_type in _scalars: return _scalars[graphene_type] return GrapheneScalarType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, serialize=getattr(graphene_type, "serialize", None), parse_value=getattr(graphene_type, "parse_value", None), parse_literal=getattr(graphene_type, "parse_literal", None), )
20,763
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.create_enum
(graphene_type)
return GrapheneEnumType( graphene_type=graphene_type, values=values, name=graphene_type._meta.name, description=type_description, )
169
205
def create_enum(graphene_type): values = {} for name, value in graphene_type._meta.enum.__members__.items(): description = getattr(value, "description", None) # if the "description" attribute is an Enum, it is likely an enum member # called description, not a description property if isinstance(description, PyEnum): description = None if not description and callable(graphene_type._meta.description): description = graphene_type._meta.description(value) deprecation_reason = getattr(value, "deprecation_reason", None) if isinstance(deprecation_reason, PyEnum): deprecation_reason = None if not deprecation_reason and callable( graphene_type._meta.deprecation_reason ): deprecation_reason = graphene_type._meta.deprecation_reason(value) values[name] = GraphQLEnumValue( value=value, description=description, deprecation_reason=deprecation_reason, ) type_description = ( graphene_type._meta.description(None) if callable(graphene_type._meta.description) else graphene_type._meta.description ) return GrapheneEnumType( graphene_type=graphene_type, values=values, name=graphene_type._meta.name, description=type_description, )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L169-L205
30
[ 0 ]
2.702703
[ 1, 2, 3, 6, 7, 8, 9, 11, 12, 13, 14, 17, 19, 25, 31 ]
40.540541
false
67.083333
37
8
59.459459
0
def create_enum(graphene_type): values = {} for name, value in graphene_type._meta.enum.__members__.items(): description = getattr(value, "description", None) # if the "description" attribute is an Enum, it is likely an enum member # called description, not a description property if isinstance(description, PyEnum): description = None if not description and callable(graphene_type._meta.description): description = graphene_type._meta.description(value) deprecation_reason = getattr(value, "deprecation_reason", None) if isinstance(deprecation_reason, PyEnum): deprecation_reason = None if not deprecation_reason and callable( graphene_type._meta.deprecation_reason ): deprecation_reason = graphene_type._meta.deprecation_reason(value) values[name] = GraphQLEnumValue( value=value, description=description, deprecation_reason=deprecation_reason, ) type_description = ( graphene_type._meta.description(None) if callable(graphene_type._meta.description) else graphene_type._meta.description ) return GrapheneEnumType( graphene_type=graphene_type, values=values, name=graphene_type._meta.name, description=type_description, )
20,764
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.create_objecttype
(self, graphene_type)
return GrapheneObjectType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, fields=partial(self.create_fields_for_type, graphene_type), is_type_of=is_type_of, interfaces=interfaces, )
207
232
def create_objecttype(self, graphene_type): create_graphql_type = self.add_type def interfaces(): interfaces = [] for graphene_interface in graphene_type._meta.interfaces: interface = create_graphql_type(graphene_interface) assert interface.graphene_type == graphene_interface interfaces.append(interface) return interfaces if graphene_type._meta.possible_types: is_type_of = partial( is_type_of_from_possible_types, graphene_type._meta.possible_types ) else: is_type_of = graphene_type.is_type_of return GrapheneObjectType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, fields=partial(self.create_fields_for_type, graphene_type), is_type_of=is_type_of, interfaces=interfaces, )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L207-L232
30
[ 0, 1, 2, 3, 4, 5, 9, 10, 11, 16, 17, 18 ]
46.153846
[ 6, 7, 8, 12 ]
15.384615
false
67.083333
26
5
84.615385
0
def create_objecttype(self, graphene_type): create_graphql_type = self.add_type def interfaces(): interfaces = [] for graphene_interface in graphene_type._meta.interfaces: interface = create_graphql_type(graphene_interface) assert interface.graphene_type == graphene_interface interfaces.append(interface) return interfaces if graphene_type._meta.possible_types: is_type_of = partial( is_type_of_from_possible_types, graphene_type._meta.possible_types ) else: is_type_of = graphene_type.is_type_of return GrapheneObjectType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, fields=partial(self.create_fields_for_type, graphene_type), is_type_of=is_type_of, interfaces=interfaces, )
20,765
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.create_interface
(self, graphene_type)
return GrapheneInterfaceType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, fields=partial(self.create_fields_for_type, graphene_type), interfaces=interfaces, resolve_type=resolve_type, )
234
258
def create_interface(self, graphene_type): resolve_type = ( partial( self.resolve_type, graphene_type.resolve_type, graphene_type._meta.name ) if graphene_type.resolve_type else None ) def interfaces(): interfaces = [] for graphene_interface in graphene_type._meta.interfaces: interface = self.add_type(graphene_interface) assert interface.graphene_type == graphene_interface interfaces.append(interface) return interfaces return GrapheneInterfaceType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, fields=partial(self.create_fields_for_type, graphene_type), interfaces=interfaces, resolve_type=resolve_type, )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L234-L258
30
[ 0 ]
4
[ 1, 9, 10, 11, 12, 13, 14, 15, 17 ]
36
false
67.083333
25
4
64
0
def create_interface(self, graphene_type): resolve_type = ( partial( self.resolve_type, graphene_type.resolve_type, graphene_type._meta.name ) if graphene_type.resolve_type else None ) def interfaces(): interfaces = [] for graphene_interface in graphene_type._meta.interfaces: interface = self.add_type(graphene_interface) assert interface.graphene_type == graphene_interface interfaces.append(interface) return interfaces return GrapheneInterfaceType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, fields=partial(self.create_fields_for_type, graphene_type), interfaces=interfaces, resolve_type=resolve_type, )
20,766
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.create_inputobjecttype
(self, graphene_type)
return GrapheneInputObjectType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, out_type=graphene_type._meta.container, fields=partial( self.create_fields_for_type, graphene_type, is_input_type=True ), )
260
269
def create_inputobjecttype(self, graphene_type): return GrapheneInputObjectType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, out_type=graphene_type._meta.container, fields=partial( self.create_fields_for_type, graphene_type, is_input_type=True ), )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L260-L269
30
[ 0, 1 ]
20
[]
0
false
67.083333
10
1
100
0
def create_inputobjecttype(self, graphene_type): return GrapheneInputObjectType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, out_type=graphene_type._meta.container, fields=partial( self.create_fields_for_type, graphene_type, is_input_type=True ), )
20,767
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.construct_union
(self, graphene_type)
return GrapheneUnionType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, types=types, resolve_type=resolve_type, )
271
296
def construct_union(self, graphene_type): create_graphql_type = self.add_type def types(): union_types = [] for graphene_objecttype in graphene_type._meta.types: object_type = create_graphql_type(graphene_objecttype) assert object_type.graphene_type == graphene_objecttype union_types.append(object_type) return union_types resolve_type = ( partial( self.resolve_type, graphene_type.resolve_type, graphene_type._meta.name ) if graphene_type.resolve_type else None ) return GrapheneUnionType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, types=types, resolve_type=resolve_type, )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L271-L296
30
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 18, 19 ]
53.846154
[]
0
false
67.083333
26
4
100
0
def construct_union(self, graphene_type): create_graphql_type = self.add_type def types(): union_types = [] for graphene_objecttype in graphene_type._meta.types: object_type = create_graphql_type(graphene_objecttype) assert object_type.graphene_type == graphene_objecttype union_types.append(object_type) return union_types resolve_type = ( partial( self.resolve_type, graphene_type.resolve_type, graphene_type._meta.name ) if graphene_type.resolve_type else None ) return GrapheneUnionType( graphene_type=graphene_type, name=graphene_type._meta.name, description=graphene_type._meta.description, types=types, resolve_type=resolve_type, )
20,768
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.get_name
(self, name)
return name
298
301
def get_name(self, name): if self.auto_camelcase: return to_camel_case(name) return name
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L298-L301
30
[ 0, 1, 2 ]
75
[ 3 ]
25
false
67.083333
4
2
75
0
def get_name(self, name): if self.auto_camelcase: return to_camel_case(name) return name
20,769
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.create_fields_for_type
(self, graphene_type, is_input_type=False)
return fields
303
371
def create_fields_for_type(self, graphene_type, is_input_type=False): create_graphql_type = self.add_type fields = {} for name, field in graphene_type._meta.fields.items(): if isinstance(field, Dynamic): field = get_field_as(field.get_type(self), _as=Field) if not field: continue field_type = create_graphql_type(field.type) if is_input_type: _field = GraphQLInputField( field_type, default_value=field.default_value, out_name=name, description=field.description, deprecation_reason=field.deprecation_reason, ) else: args = {} for arg_name, arg in field.args.items(): arg_type = create_graphql_type(arg.type) processed_arg_name = arg.name or self.get_name(arg_name) args[processed_arg_name] = GraphQLArgument( arg_type, out_name=arg_name, description=arg.description, default_value=arg.default_value, deprecation_reason=arg.deprecation_reason, ) subscribe = field.wrap_subscribe( self.get_function_for_type( graphene_type, f"subscribe_{name}", name, field.default_value ) ) # If we are in a subscription, we use (by default) an # identity-based resolver for the root, rather than the # default resolver for objects/dicts. if subscribe: field_default_resolver = identity_resolve elif issubclass(graphene_type, ObjectType): default_resolver = ( graphene_type._meta.default_resolver or get_default_resolver() ) field_default_resolver = partial( default_resolver, name, field.default_value ) else: field_default_resolver = None resolve = field.wrap_resolve( self.get_function_for_type( graphene_type, f"resolve_{name}", name, field.default_value ) or field_default_resolver ) _field = GraphQLField( field_type, args=args, resolve=resolve, subscribe=subscribe, deprecation_reason=field.deprecation_reason, description=field.description, ) field_name = field.name or self.get_name(name) fields[field_name] = _field return fields
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L303-L371
30
[ 0, 1, 2, 3, 4, 5, 9, 10, 11, 19, 20, 21, 22, 23, 30, 38, 39, 41, 42, 45, 50, 51, 57, 58, 66, 67, 68 ]
39.130435
[ 6, 7, 8, 40, 49 ]
7.246377
false
67.083333
69
12
92.753623
0
def create_fields_for_type(self, graphene_type, is_input_type=False): create_graphql_type = self.add_type fields = {} for name, field in graphene_type._meta.fields.items(): if isinstance(field, Dynamic): field = get_field_as(field.get_type(self), _as=Field) if not field: continue field_type = create_graphql_type(field.type) if is_input_type: _field = GraphQLInputField( field_type, default_value=field.default_value, out_name=name, description=field.description, deprecation_reason=field.deprecation_reason, ) else: args = {} for arg_name, arg in field.args.items(): arg_type = create_graphql_type(arg.type) processed_arg_name = arg.name or self.get_name(arg_name) args[processed_arg_name] = GraphQLArgument( arg_type, out_name=arg_name, description=arg.description, default_value=arg.default_value, deprecation_reason=arg.deprecation_reason, ) subscribe = field.wrap_subscribe( self.get_function_for_type( graphene_type, f"subscribe_{name}", name, field.default_value ) ) # If we are in a subscription, we use (by default) an # identity-based resolver for the root, rather than the # default resolver for objects/dicts. if subscribe: field_default_resolver = identity_resolve elif issubclass(graphene_type, ObjectType): default_resolver = ( graphene_type._meta.default_resolver or get_default_resolver() ) field_default_resolver = partial( default_resolver, name, field.default_value ) else: field_default_resolver = None resolve = field.wrap_resolve( self.get_function_for_type( graphene_type, f"resolve_{name}", name, field.default_value ) or field_default_resolver ) _field = GraphQLField( field_type, args=args, resolve=resolve, subscribe=subscribe, deprecation_reason=field.deprecation_reason, description=field.description, ) field_name = field.name or self.get_name(name) fields[field_name] = _field return fields
20,770
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.get_function_for_type
(self, graphene_type, func_name, name, default_value)
Gets a resolve or subscribe function for a given ObjectType
Gets a resolve or subscribe function for a given ObjectType
373
392
def get_function_for_type(self, graphene_type, func_name, name, default_value): """Gets a resolve or subscribe function for a given ObjectType""" if not issubclass(graphene_type, ObjectType): return resolver = getattr(graphene_type, func_name, None) if not resolver: # If we don't find the resolver in the ObjectType class, then try to # find it in each of the interfaces interface_resolver = None for interface in graphene_type._meta.interfaces: if name not in interface._meta.fields: continue interface_resolver = getattr(interface, func_name, None) if interface_resolver: break resolver = interface_resolver # Only if is not decorated with classmethod if resolver: return get_unbound_function(resolver)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L373-L392
30
[ 0, 1, 2, 4, 5, 6, 7, 8, 9, 15, 16, 17, 18, 19 ]
70
[ 3, 10, 11, 12, 13, 14 ]
30
false
67.083333
20
7
70
1
def get_function_for_type(self, graphene_type, func_name, name, default_value): if not issubclass(graphene_type, ObjectType): return resolver = getattr(graphene_type, func_name, None) if not resolver: # If we don't find the resolver in the ObjectType class, then try to # find it in each of the interfaces interface_resolver = None for interface in graphene_type._meta.interfaces: if name not in interface._meta.fields: continue interface_resolver = getattr(interface, func_name, None) if interface_resolver: break resolver = interface_resolver # Only if is not decorated with classmethod if resolver: return get_unbound_function(resolver)
20,771
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
TypeMap.resolve_type
(self, resolve_type_func, type_name, root, info, _type)
return default_type_resolver(root, info, return_type)
394
401
def resolve_type(self, resolve_type_func, type_name, root, info, _type): type_ = resolve_type_func(root, info) if inspect.isclass(type_) and issubclass(type_, ObjectType): return type_._meta.name return_type = self[type_name] return default_type_resolver(root, info, return_type)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L394-L401
30
[ 0, 1, 2, 3, 4, 5 ]
75
[ 6, 7 ]
25
false
67.083333
8
3
75
0
def resolve_type(self, resolve_type_func, type_name, root, info, _type): type_ = resolve_type_func(root, info) if inspect.isclass(type_) and issubclass(type_, ObjectType): return type_._meta.name return_type = self[type_name] return default_type_resolver(root, info, return_type)
20,772
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
Schema.__init__
( self, query=None, mutation=None, subscription=None, types=None, directives=None, auto_camelcase=True, )
425
446
def __init__( self, query=None, mutation=None, subscription=None, types=None, directives=None, auto_camelcase=True, ): self.query = query self.mutation = mutation self.subscription = subscription type_map = TypeMap( query, mutation, subscription, types, auto_camelcase=auto_camelcase ) self.graphql_schema = GraphQLSchema( type_map.query, type_map.mutation, type_map.subscription, type_map.types, directives, )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L425-L446
30
[ 0, 9, 10, 11, 12, 15 ]
27.272727
[]
0
false
67.083333
22
1
100
0
def __init__( self, query=None, mutation=None, subscription=None, types=None, directives=None, auto_camelcase=True, ): self.query = query self.mutation = mutation self.subscription = subscription type_map = TypeMap( query, mutation, subscription, types, auto_camelcase=auto_camelcase ) self.graphql_schema = GraphQLSchema( type_map.query, type_map.mutation, type_map.subscription, type_map.types, directives, )
20,773
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
Schema.__str__
(self)
return print_schema(self.graphql_schema)
448
449
def __str__(self): return print_schema(self.graphql_schema)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L448-L449
30
[ 0 ]
50
[ 1 ]
50
false
67.083333
2
1
50
0
def __str__(self): return print_schema(self.graphql_schema)
20,774
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
Schema.__getattr__
(self, type_name)
return _type
This function let the developer select a type in a given schema by accessing its attrs. Example: using schema.Query for accessing the "Query" type in the Schema
This function let the developer select a type in a given schema by accessing its attrs. Example: using schema.Query for accessing the "Query" type in the Schema
451
462
def __getattr__(self, type_name): """ This function let the developer select a type in a given schema by accessing its attrs. Example: using schema.Query for accessing the "Query" type in the Schema """ _type = self.graphql_schema.get_type(type_name) if _type is None: raise AttributeError(f'Type "{type_name}" not found in the Schema') if isinstance(_type, GrapheneGraphQLType): return _type.graphene_type return _type
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L451-L462
30
[ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
75
[ 9, 10, 11 ]
25
false
67.083333
12
3
75
3
def __getattr__(self, type_name): _type = self.graphql_schema.get_type(type_name) if _type is None: raise AttributeError(f'Type "{type_name}" not found in the Schema') if isinstance(_type, GrapheneGraphQLType): return _type.graphene_type return _type
20,775
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
Schema.lazy
(self, _type)
return lambda: self.get_type(_type)
464
465
def lazy(self, _type): return lambda: self.get_type(_type)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L464-L465
30
[ 0 ]
50
[ 1 ]
50
false
67.083333
2
1
50
0
def lazy(self, _type): return lambda: self.get_type(_type)
20,776
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
Schema.execute
(self, *args, **kwargs)
return graphql_sync(self.graphql_schema, *args, **kwargs)
Execute a GraphQL query on the schema. Use the `graphql_sync` function from `graphql-core` to provide the result for a query string. Most of the time this method will be called by one of the Graphene :ref:`Integrations` via a web request. Args: request_string (str or Document): GraphQL request (query, mutation or subscription) as string or parsed AST form from `graphql-core`. root_value (Any, optional): Value to use as the parent value object when resolving root types. context_value (Any, optional): Value to be made available to all resolvers via `info.context`. Can be used to share authorization, dataloaders or other information needed to resolve an operation. variable_values (dict, optional): If variables are used in the request string, they can be provided in dictionary form mapping the variable name to the variable value. operation_name (str, optional): If multiple operations are provided in the request_string, an operation name must be provided for the result to be provided. middleware (List[SupportsGraphQLMiddleware]): Supply request level middleware as defined in `graphql-core`. execution_context_class (ExecutionContext, optional): The execution context class to use when resolving queries and mutations. Returns: :obj:`ExecutionResult` containing any data and errors for the operation.
Execute a GraphQL query on the schema. Use the `graphql_sync` function from `graphql-core` to provide the result for a query string. Most of the time this method will be called by one of the Graphene :ref:`Integrations` via a web request. Args: request_string (str or Document): GraphQL request (query, mutation or subscription) as string or parsed AST form from `graphql-core`. root_value (Any, optional): Value to use as the parent value object when resolving root types. context_value (Any, optional): Value to be made available to all resolvers via `info.context`. Can be used to share authorization, dataloaders or other information needed to resolve an operation. variable_values (dict, optional): If variables are used in the request string, they can be provided in dictionary form mapping the variable name to the variable value. operation_name (str, optional): If multiple operations are provided in the request_string, an operation name must be provided for the result to be provided. middleware (List[SupportsGraphQLMiddleware]): Supply request level middleware as defined in `graphql-core`. execution_context_class (ExecutionContext, optional): The execution context class to use when resolving queries and mutations. Returns: :obj:`ExecutionResult` containing any data and errors for the operation.
467
492
def execute(self, *args, **kwargs): """Execute a GraphQL query on the schema. Use the `graphql_sync` function from `graphql-core` to provide the result for a query string. Most of the time this method will be called by one of the Graphene :ref:`Integrations` via a web request. Args: request_string (str or Document): GraphQL request (query, mutation or subscription) as string or parsed AST form from `graphql-core`. root_value (Any, optional): Value to use as the parent value object when resolving root types. context_value (Any, optional): Value to be made available to all resolvers via `info.context`. Can be used to share authorization, dataloaders or other information needed to resolve an operation. variable_values (dict, optional): If variables are used in the request string, they can be provided in dictionary form mapping the variable name to the variable value. operation_name (str, optional): If multiple operations are provided in the request_string, an operation name must be provided for the result to be provided. middleware (List[SupportsGraphQLMiddleware]): Supply request level middleware as defined in `graphql-core`. execution_context_class (ExecutionContext, optional): The execution context class to use when resolving queries and mutations. Returns: :obj:`ExecutionResult` containing any data and errors for the operation. """ kwargs = normalize_execute_kwargs(kwargs) return graphql_sync(self.graphql_schema, *args, **kwargs)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L467-L492
30
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ]
100
[]
0
true
67.083333
26
1
100
22
def execute(self, *args, **kwargs): kwargs = normalize_execute_kwargs(kwargs) return graphql_sync(self.graphql_schema, *args, **kwargs)
20,777
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
Schema.execute_async
(self, *args, **kwargs)
return await graphql(self.graphql_schema, *args, **kwargs)
Execute a GraphQL query on the schema asynchronously. Same as `execute`, but uses `graphql` instead of `graphql_sync`.
Execute a GraphQL query on the schema asynchronously. Same as `execute`, but uses `graphql` instead of `graphql_sync`.
494
499
async def execute_async(self, *args, **kwargs): """Execute a GraphQL query on the schema asynchronously. Same as `execute`, but uses `graphql` instead of `graphql_sync`. """ kwargs = normalize_execute_kwargs(kwargs) return await graphql(self.graphql_schema, *args, **kwargs)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L494-L499
30
[ 0, 1, 2, 3 ]
66.666667
[ 4, 5 ]
33.333333
false
67.083333
6
1
66.666667
2
async def execute_async(self, *args, **kwargs): kwargs = normalize_execute_kwargs(kwargs) return await graphql(self.graphql_schema, *args, **kwargs)
20,778
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
Schema.subscribe
(self, query, *args, **kwargs)
return await subscribe(self.graphql_schema, document, *args, **kwargs)
Execute a GraphQL subscription on the schema asynchronously.
Execute a GraphQL subscription on the schema asynchronously.
501
516
async def subscribe(self, query, *args, **kwargs): """Execute a GraphQL subscription on the schema asynchronously.""" # Do parsing try: document = parse(query) except GraphQLError as error: return ExecutionResult(data=None, errors=[error]) # Do validation validation_errors = validate(self.graphql_schema, document) if validation_errors: return ExecutionResult(data=None, errors=validation_errors) # Execute the query kwargs = normalize_execute_kwargs(kwargs) return await subscribe(self.graphql_schema, document, *args, **kwargs)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L501-L516
30
[ 0, 1, 2 ]
18.75
[ 3, 4, 5, 6, 9, 10, 11, 14, 15 ]
56.25
false
67.083333
16
3
43.75
1
async def subscribe(self, query, *args, **kwargs): # Do parsing try: document = parse(query) except GraphQLError as error: return ExecutionResult(data=None, errors=[error]) # Do validation validation_errors = validate(self.graphql_schema, document) if validation_errors: return ExecutionResult(data=None, errors=validation_errors) # Execute the query kwargs = normalize_execute_kwargs(kwargs) return await subscribe(self.graphql_schema, document, *args, **kwargs)
20,779
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/schema.py
Schema.introspect
(self)
return introspection.data
518
522
def introspect(self): introspection = self.execute(introspection_query) if introspection.errors: raise introspection.errors[0] return introspection.data
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/schema.py#L518-L522
30
[ 0 ]
20
[ 1, 2, 3, 4 ]
80
false
67.083333
5
2
20
0
def introspect(self): introspection = self.execute(introspection_query) if introspection.errors: raise introspection.errors[0] return introspection.data
20,780
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/uuid.py
UUID.serialize
(uuid)
return str(uuid)
17
22
def serialize(uuid): if isinstance(uuid, str): uuid = _UUID(uuid) assert isinstance(uuid, _UUID), f"Expected UUID instance, received {uuid}" return str(uuid)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/uuid.py#L17-L22
30
[ 0 ]
16.666667
[ 1, 2, 4, 5 ]
66.666667
false
70
6
3
33.333333
0
def serialize(uuid): if isinstance(uuid, str): uuid = _UUID(uuid) assert isinstance(uuid, _UUID), f"Expected UUID instance, received {uuid}" return str(uuid)
20,781
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/uuid.py
UUID.parse_literal
(node, _variables=None)
return Undefined
25
28
def parse_literal(node, _variables=None): if isinstance(node, StringValueNode): return _UUID(node.value) return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/uuid.py#L25-L28
30
[ 0, 1, 2 ]
75
[ 3 ]
25
false
70
4
2
75
0
def parse_literal(node, _variables=None): if isinstance(node, StringValueNode): return _UUID(node.value) return Undefined
20,782
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/uuid.py
UUID.parse_value
(value)
return _UUID(value)
31
32
def parse_value(value): return _UUID(value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/uuid.py#L31-L32
30
[ 0 ]
50
[ 1 ]
50
false
70
2
1
50
0
def parse_value(value): return _UUID(value)
20,783
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
Scalar.__init_subclass_with_meta__
(cls, **options)
29
31
def __init_subclass_with_meta__(cls, **options): _meta = ScalarOptions(cls) super(Scalar, cls).__init_subclass_with_meta__(_meta=_meta, **options)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L29-L31
30
[ 0, 1, 2 ]
100
[]
0
true
58.252427
3
1
100
0
def __init_subclass_with_meta__(cls, **options): _meta = ScalarOptions(cls) super(Scalar, cls).__init_subclass_with_meta__(_meta=_meta, **options)
20,784
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
Scalar.get_type
(cls)
return cls
This function is called when the unmounted type (Scalar instance) is mounted (as a Field, InputField or Argument)
This function is called when the unmounted type (Scalar instance) is mounted (as a Field, InputField or Argument)
38
43
def get_type(cls): """ This function is called when the unmounted type (Scalar instance) is mounted (as a Field, InputField or Argument) """ return cls
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L38-L43
30
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
58.252427
6
1
100
2
def get_type(cls): return cls
20,785
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
Int.coerce_int
(value)
return Undefined
64
74
def coerce_int(value): try: num = int(value) except ValueError: try: num = int(float(value)) except ValueError: return Undefined if MIN_INT <= num <= MAX_INT: return num return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L64-L74
30
[ 0 ]
9.090909
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
90.909091
false
58.252427
11
4
9.090909
0
def coerce_int(value): try: num = int(value) except ValueError: try: num = int(float(value)) except ValueError: return Undefined if MIN_INT <= num <= MAX_INT: return num return Undefined
20,786
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
Int.parse_literal
(ast, _variables=None)
return Undefined
80
85
def parse_literal(ast, _variables=None): if isinstance(ast, IntValueNode): num = int(ast.value) if MIN_INT <= num <= MAX_INT: return num return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L80-L85
30
[ 0 ]
16.666667
[ 1, 2, 3, 4, 5 ]
83.333333
false
58.252427
6
3
16.666667
0
def parse_literal(ast, _variables=None): if isinstance(ast, IntValueNode): num = int(ast.value) if MIN_INT <= num <= MAX_INT: return num return Undefined
20,787
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
BigInt.coerce_int
(value)
return num
96
104
def coerce_int(value): try: num = int(value) except ValueError: try: num = int(float(value)) except ValueError: return Undefined return num
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L96-L104
30
[ 0 ]
11.111111
[ 1, 2, 3, 4, 5, 6, 7, 8 ]
88.888889
false
58.252427
9
3
11.111111
0
def coerce_int(value): try: num = int(value) except ValueError: try: num = int(float(value)) except ValueError: return Undefined return num
20,788
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
BigInt.parse_literal
(ast, _variables=None)
return Undefined
110
113
def parse_literal(ast, _variables=None): if isinstance(ast, IntValueNode): return int(ast.value) return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L110-L113
30
[ 0, 1, 2 ]
75
[ 3 ]
25
false
58.252427
4
2
75
0
def parse_literal(ast, _variables=None): if isinstance(ast, IntValueNode): return int(ast.value) return Undefined
20,789
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
Float.coerce_float
(value)
124
129
def coerce_float(value): # type: (Any) -> float try: return float(value) except ValueError: return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L124-L129
30
[ 0, 1 ]
33.333333
[ 2, 3, 4, 5 ]
66.666667
false
58.252427
6
2
33.333333
0
def coerce_float(value): # type: (Any) -> float try: return float(value) except ValueError: return Undefined
20,790
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
Float.parse_literal
(ast, _variables=None)
return Undefined
135
138
def parse_literal(ast, _variables=None): if isinstance(ast, (FloatValueNode, IntValueNode)): return float(ast.value) return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L135-L138
30
[ 0 ]
25
[ 1, 2, 3 ]
75
false
58.252427
4
2
25
0
def parse_literal(ast, _variables=None): if isinstance(ast, (FloatValueNode, IntValueNode)): return float(ast.value) return Undefined
20,791
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
String.coerce_string
(value)
return str(value)
149
152
def coerce_string(value): if isinstance(value, bool): return "true" if value else "false" return str(value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L149-L152
30
[ 0 ]
25
[ 1, 2, 3 ]
75
false
58.252427
4
2
25
0
def coerce_string(value): if isinstance(value, bool): return "true" if value else "false" return str(value)
20,792
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
String.parse_literal
(ast, _variables=None)
return Undefined
158
161
def parse_literal(ast, _variables=None): if isinstance(ast, StringValueNode): return ast.value return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L158-L161
30
[ 0 ]
25
[ 1, 2, 3 ]
75
false
58.252427
4
2
25
0
def parse_literal(ast, _variables=None): if isinstance(ast, StringValueNode): return ast.value return Undefined
20,793
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
Boolean.parse_literal
(ast, _variables=None)
return Undefined
173
176
def parse_literal(ast, _variables=None): if isinstance(ast, BooleanValueNode): return ast.value return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L173-L176
30
[ 0 ]
25
[ 1, 2, 3 ]
75
false
58.252427
4
2
25
0
def parse_literal(ast, _variables=None): if isinstance(ast, BooleanValueNode): return ast.value return Undefined
20,794
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/scalars.py
ID.parse_literal
(ast, _variables=None)
return Undefined
192
195
def parse_literal(ast, _variables=None): if isinstance(ast, (StringValueNode, IntValueNode)): return ast.value return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/scalars.py#L192-L195
30
[ 0 ]
25
[ 1, 2, 3 ]
75
false
58.252427
4
2
25
0
def parse_literal(ast, _variables=None): if isinstance(ast, (StringValueNode, IntValueNode)): return ast.value return Undefined
20,795
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/enum.py
eq_enum
(self, other)
return self.value is other
9
12
def eq_enum(self, other): if isinstance(other, self.__class__): return self is other return self.value is other
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/enum.py#L9-L12
30
[ 0 ]
25
[ 1, 2, 3 ]
75
false
83.018868
4
2
25
0
def eq_enum(self, other): if isinstance(other, self.__class__): return self is other return self.value is other
20,796
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/enum.py
hash_enum
(self)
return hash(self.name)
15
16
def hash_enum(self): return hash(self.name)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/enum.py#L15-L16
30
[ 0 ]
50
[ 1 ]
50
false
83.018868
2
1
50
0
def hash_enum(self): return hash(self.name)
20,797
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/enum.py
EnumMeta.__new__
(cls, name_, bases, classdict, **options)
return SubclassWithMeta_Meta.__new__( cls, name_, bases, dict(classdict, __enum__=enum), **options )
28
36
def __new__(cls, name_, bases, classdict, **options): enum_members = dict(classdict, __eq__=eq_enum, __hash__=hash_enum) # We remove the Meta attribute from the class to not collide # with the enum values. enum_members.pop("Meta", None) enum = PyEnum(cls.__name__, enum_members) return SubclassWithMeta_Meta.__new__( cls, name_, bases, dict(classdict, __enum__=enum), **options )
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/enum.py#L28-L36
30
[ 0, 1, 2, 3, 4, 5, 6 ]
77.777778
[]
0
false
83.018868
9
1
100
0
def __new__(cls, name_, bases, classdict, **options): enum_members = dict(classdict, __eq__=eq_enum, __hash__=hash_enum) # We remove the Meta attribute from the class to not collide # with the enum values. enum_members.pop("Meta", None) enum = PyEnum(cls.__name__, enum_members) return SubclassWithMeta_Meta.__new__( cls, name_, bases, dict(classdict, __enum__=enum), **options )
20,798
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/enum.py
EnumMeta.get
(cls, value)
return cls._meta.enum(value)
38
39
def get(cls, value): return cls._meta.enum(value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/enum.py#L38-L39
30
[ 0 ]
50
[ 1 ]
50
false
83.018868
2
1
50
0
def get(cls, value): return cls._meta.enum(value)
20,799
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/enum.py
EnumMeta.__getitem__
(cls, value)
return cls._meta.enum[value]
41
42
def __getitem__(cls, value): return cls._meta.enum[value]
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/enum.py#L41-L42
30
[ 0 ]
50
[ 1 ]
50
false
83.018868
2
1
50
0
def __getitem__(cls, value): return cls._meta.enum[value]
20,800
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/enum.py
EnumMeta.__prepare__
(name, bases, **kwargs)
return {}
44
45
def __prepare__(name, bases, **kwargs): # noqa: N805 return {}
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/enum.py#L44-L45
30
[ 0, 1 ]
100
[]
0
true
83.018868
2
1
100
0
def __prepare__(name, bases, **kwargs): # noqa: N805 return {}
20,801
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/enum.py
EnumMeta.__call__
(cls, *args, **kwargs)
return super(EnumMeta, cls).__call__(*args, **kwargs)
47
56
def __call__(cls, *args, **kwargs): # noqa: N805 if cls is Enum: description = kwargs.pop("description", None) deprecation_reason = kwargs.pop("deprecation_reason", None) return cls.from_enum( PyEnum(*args, **kwargs), description=description, deprecation_reason=deprecation_reason, ) return super(EnumMeta, cls).__call__(*args, **kwargs)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/enum.py#L47-L56
30
[ 0, 1, 2, 3, 4 ]
50
[ 9 ]
10
false
83.018868
10
2
90
0
def __call__(cls, *args, **kwargs): # noqa: N805 if cls is Enum: description = kwargs.pop("description", None) deprecation_reason = kwargs.pop("deprecation_reason", None) return cls.from_enum( PyEnum(*args, **kwargs), description=description, deprecation_reason=deprecation_reason, ) return super(EnumMeta, cls).__call__(*args, **kwargs)
20,802
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/enum.py
EnumMeta.__iter__
(cls)
return cls._meta.enum.__iter__()
59
60
def __iter__(cls): return cls._meta.enum.__iter__()
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/enum.py#L59-L60
30
[ 0 ]
50
[ 1 ]
50
false
83.018868
2
1
50
0
def __iter__(cls): return cls._meta.enum.__iter__()
20,803
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/enum.py
EnumMeta.from_enum
( cls, enum, name=None, description=None, deprecation_reason=None )
return type(name, (Enum,), {"Meta": meta_class})
62
73
def from_enum( cls, enum, name=None, description=None, deprecation_reason=None ): # noqa: N805 name = name or enum.__name__ description = description or enum.__doc__ meta_dict = { "enum": enum, "description": description, "deprecation_reason": deprecation_reason, } meta_class = type("Meta", (object,), meta_dict) return type(name, (Enum,), {"Meta": meta_class})
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/enum.py#L62-L73
30
[ 0, 3, 4, 5, 10, 11 ]
50
[]
0
false
83.018868
12
3
100
0
def from_enum( cls, enum, name=None, description=None, deprecation_reason=None ): # noqa: N805 name = name or enum.__name__ description = description or enum.__doc__ meta_dict = { "enum": enum, "description": description, "deprecation_reason": deprecation_reason, } meta_class = type("Meta", (object,), meta_dict) return type(name, (Enum,), {"Meta": meta_class})
20,804
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/enum.py
Enum.__init_subclass_with_meta__
(cls, enum=None, _meta=None, **options)
102
110
def __init_subclass_with_meta__(cls, enum=None, _meta=None, **options): if not _meta: _meta = EnumOptions(cls) _meta.enum = enum or cls.__enum__ _meta.deprecation_reason = options.pop("deprecation_reason", None) for key, value in _meta.enum.__members__.items(): setattr(cls, key, value) super(Enum, cls).__init_subclass_with_meta__(_meta=_meta, **options)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/enum.py#L102-L110
30
[ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
100
[]
0
true
83.018868
9
4
100
0
def __init_subclass_with_meta__(cls, enum=None, _meta=None, **options): if not _meta: _meta = EnumOptions(cls) _meta.enum = enum or cls.__enum__ _meta.deprecation_reason = options.pop("deprecation_reason", None) for key, value in _meta.enum.__members__.items(): setattr(cls, key, value) super(Enum, cls).__init_subclass_with_meta__(_meta=_meta, **options)
20,805
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/enum.py
Enum.get_type
(cls)
return cls
This function is called when the unmounted type (Enum instance) is mounted (as a Field, InputField or Argument)
This function is called when the unmounted type (Enum instance) is mounted (as a Field, InputField or Argument)
113
118
def get_type(cls): """ This function is called when the unmounted type (Enum instance) is mounted (as a Field, InputField or Argument) """ return cls
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/enum.py#L113-L118
30
[ 0, 1, 2, 3, 4 ]
83.333333
[ 5 ]
16.666667
false
83.018868
6
1
83.333333
2
def get_type(cls): return cls
20,806
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/definitions.py
GrapheneGraphQLType.__init__
(self, *args, **kwargs)
19
21
def __init__(self, *args, **kwargs): self.graphene_type = kwargs.pop("graphene_type") super(GrapheneGraphQLType, self).__init__(*args, **kwargs)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/definitions.py#L19-L21
30
[ 0, 1, 2 ]
100
[]
0
true
59.375
3
1
100
0
def __init__(self, *args, **kwargs): self.graphene_type = kwargs.pop("graphene_type") super(GrapheneGraphQLType, self).__init__(*args, **kwargs)
20,807
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/definitions.py
GrapheneGraphQLType.__copy__
(self)
return result
23
26
def __copy__(self): result = GrapheneGraphQLType(graphene_type=self.graphene_type) result.__dict__.update(self.__dict__) return result
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/definitions.py#L23-L26
30
[ 0 ]
25
[ 1, 2, 3 ]
75
false
59.375
4
1
25
0
def __copy__(self): result = GrapheneGraphQLType(graphene_type=self.graphene_type) result.__dict__.update(self.__dict__) return result
20,808
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/definitions.py
GrapheneEnumType.serialize
(self, value)
return super(GrapheneEnumType, self).serialize(value)
46
58
def serialize(self, value): if not isinstance(value, PyEnum): enum = self.graphene_type._meta.enum try: # Try and get enum by value value = enum(value) except ValueError: # Try and get enum by name try: value = enum[value] except KeyError: pass return super(GrapheneEnumType, self).serialize(value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/definitions.py#L46-L58
30
[ 0 ]
7.692308
[ 1, 2, 3, 5, 6, 8, 9, 10, 11, 12 ]
76.923077
false
59.375
13
4
23.076923
0
def serialize(self, value): if not isinstance(value, PyEnum): enum = self.graphene_type._meta.enum try: # Try and get enum by value value = enum(value) except ValueError: # Try and get enum by name try: value = enum[value] except KeyError: pass return super(GrapheneEnumType, self).serialize(value)
20,809
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/json.py
JSONString.serialize
(dt)
return json.dumps(dt)
20
21
def serialize(dt): return json.dumps(dt)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/json.py#L20-L21
30
[ 0 ]
50
[ 1 ]
50
false
75
2
1
50
0
def serialize(dt): return json.dumps(dt)
20,810
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/json.py
JSONString.parse_literal
(node, _variables=None)
return Undefined
24
30
def parse_literal(node, _variables=None): if isinstance(node, StringValueNode): try: return json.loads(node.value) except Exception as error: raise ValueError(f"Badly formed JSONString: {str(error)}") return Undefined
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/json.py#L24-L30
30
[ 0, 1, 2, 3 ]
57.142857
[ 4, 5, 6 ]
42.857143
false
75
7
3
57.142857
0
def parse_literal(node, _variables=None): if isinstance(node, StringValueNode): try: return json.loads(node.value) except Exception as error: raise ValueError(f"Badly formed JSONString: {str(error)}") return Undefined
20,811
graphql-python/graphene
52143473efad141f6700237ecce79b22e8ff4e41
graphene/types/json.py
JSONString.parse_value
(value)
return json.loads(value)
33
34
def parse_value(value): return json.loads(value)
https://github.com/graphql-python/graphene/blob/52143473efad141f6700237ecce79b22e8ff4e41/project30/graphene/types/json.py#L33-L34
30
[ 0 ]
50
[ 1 ]
50
false
75
2
1
50
0
def parse_value(value): return json.loads(value)
20,812