Using the optimizer, I get the error "must be str, not Prefetch"
See original GitHub issueI have some django models:
class UserWorkspace(SafeDeleteModel):
name = models.CharField(max_length=50)
user = models.ForeignKey(User, on_delete=models.CASCADE)
instance_groups = models.ManyToManyField(InstanceGroup)
class InstanceGroup(SafeDeleteModel):
instances = models.ManyToManyField(project)
class project(SafeDeleteModel):
"""
Projects
"""
uploaded_file = models.ForeignKey('primavera.UploadedFile', on_delete=models.CASCADE)
proj_id = models.IntegerField(null=True, help_text="FK to PROJECT table - identifies the project")
# ...........................
class task(SafeDeleteModel):
"""
Activities
"""
uploaded_file = models.ForeignKey('primavera.UploadedFile', on_delete=models.CASCADE)
task_id = models.IntegerField(null=True, help_text="FK to TASK table - identifies the task")
proj_id = models.ForeignKey(null=True, help_text="FK to PROJECT table - identifies the project", to="project", on_delete=models.CASCADE, related_name="tasks")
# ............................
The query looks like this:
def resolver_for_model(model):
return lambda root, info, **kwargs: gql_optimizer.query(model.objects.all(), info)
class BaseQuery():
all_user_workspace = graphene.List(type_for_model(UserWorkspace), resolver=resolver_for_model(UserWorkspace))
When I run this query:
{
allUserWorkspace {
id
name
instanceGroups {
instances {
lastRecalcDate
id
tasks {
id
}
}
}
}
}
I get this error:
graphql.error.located_error.GraphQLLocatedError: must be str, not Prefetch
I looked at that code and tried to replicate the problem by running something like this:
Instance.objects.all().prefetch_related(Prefetch('tasks'))
This works just fine though. I’m not sure what could be causing this error.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
I get the error "must be str, not builtin_function_or_method"
A new file is created by comparing the information from the average speed recording system with the file of registered vehicles and their...
Read more >FullyShardedDataParallel — PyTorch 1.13 documentation
The optimizer must be initialized after the module has been wrapped, since FSDP will shard parameters in-place and this will break any previously...
Read more >QuerySet API reference | Django documentation
Returns a new QuerySet containing objects that do not match the given lookup parameters. The lookup parameters ( **kwargs ) should be in...
Read more >Resource Hints - W3C
A resource hint link is a dns-prefetch , preconnect , prefetch , or prerender relationship that is used to indicate an origin or...
Read more >qopt-prefetch, Qopt-prefetch - Intel
The goal of prefetching is to reduce cache misses by providing hints to the processor about when data should be loaded into the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi! Sorry for the long time. It’s solved in v0.3.6!
Thank you very much!