def bake(self, schema: "GraphQLSchema") -> None: """ Sets the resolver coercers into the schema field definition. :param schema: the GraphQLSchema instance linked to the resolver :type schema: GraphQLSchema """ if not self._implementation: raise MissingImplementation( f"No implementation given for resolver < {self.name} >" ) try: field = schema.get_field_by_name(self.name) field.raw_resolver = self._implementation field.query_arguments_coercer = self._arguments_coercer field_wrapped_type = get_wrapped_type( get_graphql_type(schema, field.gql_type) ) if self._type_resolver and field_wrapped_type.is_abstract_type: field_wrapped_type.add_field_type_resolver( self.name, self._type_resolver ) except KeyError: raise UnknownFieldDefinition( f"Unknown Field Definition {self.name}" )
def bake(self, schema: "GraphQLSchema") -> None: """ Sets the subscription generator into the schema subscription definition. :param schema: the GraphQLSchema instance linked to the subscription :type schema: GraphQLSchema """ if not self._implementation: raise MissingImplementation( f"No implementation given for subscription < {self.name} >") try: field = schema.get_field_by_name(self.name) except KeyError: raise UnknownFieldDefinition( f"Unknown Field Definition {self.name}") parent_type_name = self.name.split(".")[0] if parent_type_name != schema.subscription_operation_name: raise NotSubscriptionField( "Field < %s > isn't a subscription field." % self.name) field.subscribe = self._implementation field.subscription_arguments_coercer = self._arguments_coercer field.subscription_concurrently = self._concurrently
def call_onbuild_directives(self) -> None: for name, directive in self._directives.items(): try: directive.implementation.on_build(self) except AttributeError: raise MissingImplementation( "directive `{}` is missing an implementation".format(name))
def bake(self, schema: "GraphQLSchema") -> None: if not self._implementation: raise MissingImplementation( "No implementation given for directive < %s >" % self._name) try: directive = schema.find_directive(self._name) directive.implementation = self._implementation except KeyError: raise UnknownDirectiveDefinition("Unknow Directive Definition %s" % self._name)
def bake(self, schema: "GraphQLSchema") -> None: if not self._implementation: raise MissingImplementation( "No implementation given for scalar < %s >" % self._name) scalar = schema.find_scalar(self._name) if not scalar: raise UnknownScalarDefinition("Unknow Scalar Definition %s" % self._name) scalar.coerce_output = self._implementation.coerce_output scalar.coerce_input = self._implementation.coerce_input
def bake(self, schema: "GraphQLSchema") -> None: if not self._implementation: raise MissingImplementation( "No implementation given for resolver < %s >" % self._name ) try: field = schema.get_field_by_name(self._name) field.resolver.update_func(self._implementation) except KeyError: raise UnknownFieldDefinition( "Unknown Field Definition %s" % self._name )
def bake(self, schema: "GraphQLSchema") -> None: """ Sets the directive implementation into the schema directive definition. :param schema: the GraphQLSchema instance linked to the directive :type schema: GraphQLSchema """ if not self._implementation: raise MissingImplementation( f"No implementation given for directive < {self.name} >") try: directive = schema.find_directive(self.name) directive.implementation = self._implementation except KeyError: raise UnknownDirectiveDefinition( f"Unknown Directive Definition {self.name}")
def bake(self, schema: "GraphQLSchema") -> None: """ Sets the scalar coercers into the schema scalar definition. :param schema: the GraphQLSchema instance linked to the scalar :type schema: GraphQLSchema """ if not self._implementation: raise MissingImplementation( f"No implementation given for scalar < {self.name} >") scalar = schema.find_scalar(self.name) if not scalar: raise UnknownScalarDefinition( f"Unknown Scalar Definition {self.name}") scalar.coerce_output = self._implementation.coerce_output scalar.coerce_input = self._implementation.coerce_input scalar.parse_literal = self._implementation.parse_literal
def bake(self, schema: "GraphQLSchema") -> None: if not self._implementation: raise MissingImplementation( "No implementation given for subscription < %s >" % self._name) try: field = schema.get_field_by_name(self._name) except KeyError: raise UnknownFieldDefinition("Unknown Field Definition %s" % self._name) # TODO: check that decorated parent decorated field is the # subscription field # if field.parent_type is not schema.find_type(schema.subscription_type): # raise NotSubscriptionField( # "< %s > isn't a subscription field." % self._name # ) field.subscribe = self._implementation
def bake(self, schema: "GraphQLSchema") -> None: """ Sets the type resolver into the schema abstract type definition. :param schema: the GraphQLSchema instance linked to the type resolver :type schema: GraphQLSchema """ if not self._implementation: raise MissingImplementation( f"No implementation given for type resolver < {self.name} >") try: graphql_type = schema.find_type(self.name) if not graphql_type.is_abstract_type: raise InvalidType( f"Type < {self.name} > is not an abstract type.") graphql_type.type_resolver = self._implementation except KeyError: raise UnknownTypeDefinition( f"Unknown Type Definition < {self.name} >.")