下面的我的石墨烯查询(我在其中将参数传递给查询)将返回所有结果,即使前端提供正确的参数时也会返回所有结果。即使没有结果应该返回的数据,它仍然会返回所有结果。
我有一个石墨烯类型:
class TimeStampType(DjangoObjectType):
rowid=graphene.Int()
class Meta:
model = TimeStamp
interfaces = (Node, )
filter_fields = {
'year': ['exact'],
'week': ['exact'],
'weekDay': ['exact'],
'shift': ['exact'],
'time': ['exact'],
'shortDate': ['exact'],
}
def resolve_rowid(self, context, **kwargs):
return self.id
带有查询:
node_timestamp = DjangoFilterConnectionField(TimeStampType)
我的查询如下所示:
query nodeTimeStamp($year:Float, $week:Float, $weekDay:Float){
nodeTimestamp(year:$year, week:$week, weekDay:$weekDay) {
edges{
node{
id
rowid
}
}
}
}
答案 0 :(得分:0)
我最终发现,由于某种原因,我应该将Apollo查询从中更改(不知道我看到的第一个方法是哪个示例,也许是一些旧文档)
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "--max_old_space_size=8192" "%~dp0\node_modules\@angular\cli\bin\ng" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "--max_old_space_size=8192" "%~dp0\node_modules\@angular\cli\bin\ng" %*
)
并删除$符号,使其显示为:
from django.db import models
class Stock(models.Model):
product_name = models.CharField(max_length=100,blank=False)
quantity = models.IntegerField()
price = models.FloatField()
status = models.CharField(max_length=10, default='AVAILABLE')
def __str__(self):
return 'Product name:{0} Quantity:{1} Price:{2} Status:{3} '.format(self.product_name, self.quantity, self.price, self.status)
class Sale(models.Model):
product_name = models.CharField(max_length=100, blank=False)
quantity = models.IntegerField()
price = models.FloatField()
status = models.CharField(max_length=10, default='SOLD')
def __str__(self):
return 'Product name:{0} Quantity:{1} Price:{2} Status:{3}'.format(self.product_name, self.quantity, self.price, self.status)
class Purchase(models.Model):
product_name = models.CharField(max_length=100,blank=False)
quantity = models.IntegerField()
price = models.FloatField()
status = models.CharField(max_length=10,default='Purchased')
def __str__(self):
return 'Product name:{0} Quantity:{1} Price:{2} Status:{3}'.format(self.product_name,self.quantity, self.price, self.status)
所以基本上我是通过该变量发送变量的,所以查询返回了所有数据。