def args_selection_search(self, selection_set, variables, parent_type, arg_name, arg_value): """Recursively search through feild/fragment selection set fields.""" for field in selection_set.selections: if isinstance(field, ast.FragmentSpread): if field.name.value in self.visited_fragments: continue frag_def = self.fragment_defs[field.name.value] frag_type = type_from_ast(self.schema, frag_def.type_condition) if self.args_selection_search(frag_def.selection_set, variables, frag_type, arg_name, arg_value): return True self.visited_fragments.add(frag_def.name) continue field_def = get_field_def(self.schema, parent_type, field.name.value) if field_def is None: continue arg_vals = get_argument_values(field_def.args, field.arguments, variables) if arg_vals.get(arg_name) == arg_value: return True if field.selection_set is None: continue if self.args_selection_search(field.selection_set, variables, get_named_type(field_def.type), arg_name, arg_value): return True return False
def enter(*args): parent_type = type_info.get_parent_type() type_ = type_info.get_type() input_type = type_info.get_input_type() node = args[0] visited.append( ( "enter", node.kind, node.value if node.kind == "name" else None, str(parent_type) if parent_type else None, str(type_) if type_ else None, str(input_type) if input_type else None, ) ) # Make a query valid by adding missing selection sets. if ( node.kind == "field" and not node.selection_set and is_composite_type(get_named_type(type_)) ): return FieldNode( alias=node.alias, name=node.name, arguments=node.arguments, directives=node.directives, selection_set=SelectionSetNode( selections=[FieldNode(name=NameNode(value="__typename"))] ), )
def enter(self, node, key, parent, *args): # type: (Any, Union[None, int, str], Any, *List[Any]) -> Optional[Any] parent_type = type_info.get_parent_type() _type = type_info.get_type() input_type = type_info.get_input_type() visited.append( [ "enter", type(node).__name__, node.value if type(node).__name__ == "Name" else None, str(parent_type) if parent_type else None, str(_type) if _type else None, str(input_type) if input_type else None, ] ) # Make a query valid by adding missing selection sets. if ( type(node).__name__ == "Field" and not node.selection_set and is_composite_type(get_named_type(_type)) ): return Field( alias=node.alias, name=node.name, arguments=node.arguments, directives=node.directives, selection_set=SelectionSet([Field(name=Name(value="__typename"))]), )
def enter(self, node, key, parent, *args): parent_type = type_info.get_parent_type() _type = type_info.get_type() input_type = type_info.get_input_type() visited.append([ 'enter', type(node).__name__, node.value if type(node).__name__ == "Name" else None, str(parent_type) if parent_type else None, str(_type) if _type else None, str(input_type) if input_type else None ]) # Make a query valid by adding missing selection sets. if type( node ).__name__ == "Field" and not node.selection_set and is_composite_type( get_named_type(_type)): return Field(alias=node.alias, name=node.name, arguments=node.arguments, directives=node.directives, selection_set=SelectionSet( [Field(name=Name(value='__typename'))]))
def unwraps_deeply_wrapper_types(): assert (get_named_type( GraphQLNonNull(GraphQLList(GraphQLNonNull(ObjectType)))) is ObjectType)
def unwraps_wrapper_types(): assert get_named_type(GraphQLNonNull(ObjectType)) is ObjectType assert get_named_type(GraphQLList(ObjectType)) is ObjectType
def returns_self_for_an_unwrapped_type(): assert get_named_type(ObjectType) is ObjectType
def returns_none_for_no_type(): assert get_named_type(None) is None
def enter(self, node, key, parent, *args): parent_type = type_info.get_parent_type() _type = type_info.get_type() input_type = type_info.get_input_type() visited.append([ 'enter', type(node).__name__, node.value if type(node).__name__ == "Name" else None, str(parent_type) if parent_type else None, str(_type) if _type else None, str(input_type) if input_type else None ]) # Make a query valid by adding missing selection sets. if type(node).__name__ == "Field" and not node.selection_set and is_composite_type(get_named_type(_type)): return Field( alias=node.alias, name=node.name, arguments=node.arguments, directives=node.directives, selection_set=SelectionSet( [Field(name=Name(value='__typename'))] ) )