-
Notifications
You must be signed in to change notification settings - Fork 28
Error: Directive "external" may not be used on ARGUMENT_DEFINITION. #26
Comments
Thanks for reporting! |
Sure! ExamResult type has an external user. But other type haven them as well. Plan.py in payment/types/plan.py from graphene_federation import key
from graphene_mongo import MongoengineObjectType
from src.models import PlanModel
@key('id')
class Plan(MongoengineObjectType):
class Meta:
model = PlanModel ExamResult.py in doc/types/exam_result.py import graphene
from graphene_mongo import MongoengineObjectType
from graphene_federation import key
from src.models import ExamResultModel
from .exam import Exam
from .material import Material
from .topic import Topic
from .user import User
@key('id')
class ExamResult(MongoengineObjectType):
exam = graphene.Field(Exam)
material = graphene.Field(Material)
gaps = graphene.List(Topic)
user = graphene.Field(User)
class Meta:
model = ExamResultModel external User in doc/types/user.py import graphene
from graphene_federation import extend, external
@extend('id')
class User(graphene.ObjectType):
id = external(graphene.ID()) I need to overwrite external relations, because by default |
@erebus1 We are facing the same issue. Any ideas or pointers? |
After a lot of investigation, it turns out that the regex is marking wrong occurrences when you try to use the external directive on a DjangoObjectType's field. |
@firaskafri Thanks for an investigation! |
@firaskafri Can you please provide an example when you're using As I understand if the field is of type DjangoObjectType - then this means this is a base type and should not be marked as external Or you mean that this type is defined in another service? |
I am experiencing a similar issue but receiving I have a Django model that stores an id and a set of objects (ManyToMany). This model is an extension of a model in another service where the id's match. The schema is setup as Service 1 @key(fields="id")
class MyObjectNode(DjangoObjectType):
class Meta:
model = MyObject
interfaces = (RelayNode,)
Service 2 @extends(fields="id")
class MyObjectNode(DjangoObjectType):
id = external(ID(required=True))
related_object_set = DjangoConnectionField(RelatedObjectNode)
def resolve_related_object_set(self, info):
return self.related_object_set.all()
class Meta:
model = MyObject
interfaces = (RelayNode,) I have two mutation classes that adds/removes class AddRelatedObjectMutation(graphene.Mutation):
class Arguments:
id = graphene.UUID(required=True)
related_objects = graphene.List(graphene.UUID, required=True)
my_object = graphene.Field(MyObjectNode)
errors = graphene.List(
ErrorType, description="May contain more than one error for same field."
)
def mutate(self, info, id, related_objects):
my_object = MyObject.objects.get(pk=id)
my_object.related_objects.add(*related_objects)
return AddRelatedObject(my_object=my_object, errors=None)
class RemoveRelatedObjectMutation(graphene.Mutation):
class Arguments:
id = graphene.UUID(required=True)
related_objects = graphene.List(graphene.UUID, required=True)
my_object = graphene.Field(MyObjectNode)
errors = graphene.List(
ErrorType, description="May contain more than one error for same field."
)
def mutate(self, info, id, related_objects):
my_object = MyObject.objects.get(pk=id)
my_object.related_objects.remove(*related_objects)
return RemoveRelatedObjectMutation(my_object=my_object, errors=None)
class Mutation(graphene.ObjectType):
add_related_objects = AddRelatedObjectMutation.Field()
remove_related_objects = RemoveRelatedMutation.Field() If I swap out Edit: Simply renaming the |
@erebus1 True in our case the type is defined in another service. |
Schema:
After checking what the regex matches on my mutation schema, I noticed it will match the following:
And will proceed to add Perhaps looking for |
Guys, thanks a lot for your help with an investigation! @jtesch @firaskafri @fabianriewe Can you please test 0.0.6 version in your projects, and report if any issue with external is still there? |
I close an issue |
Facing this error when using This Node is inside an extended Node as a DjangoFilterConnectionField. A turnaround solution to this problem is to pass the id to the resolver. If I am not the only one facing this problem when trying to filter, please open this issue |
Hey, I just upgraded my project to a new version. I was using version 0.0.2 and everything was working fine. By upgrading to version >=0.0.4. I got the following errors in my Apollo gateway:
Both of my types are not using any external arguments.
Do you have any ideas on this?
The text was updated successfully, but these errors were encountered: