我试图弄清楚如何接受一个参数并在GraphQL的子表中对该字段进行查询。
这是一个例子。
query{
allModels{
edges{
node{
featureVectors(featureSize: 128){ #I want to query on this
edges{
node{
modelSize
featureVectors
}
}
}
}
}
}
}
这里是我用来查询数据的地方。它可以查询数据,但我希望能够传递参数来搜索特定的特征,例如featureVectors(featureSize:128)。我似乎在Graphene-SQLAlchemy库中找不到任何可以原生允许的方法。
class ModelModel(Base):
__tablename__ = 'models'
id = Column(Integer, primary_key=True, server_default=text("nextval('models_id_seq'::regclass)"))
type = Column(Text)
components = Column(Float)
notes = Column(Text)
feature_vectors = relationship("FeatureVector", back_populates='models')
class FeatureVectorModel(Base):
id = Column(BigInteger, primary_key=True, server_default=text("nextval('feature_vectors_id_seq'::regclass)"))
model_size = Column(Integer)
feature_vectors = Column(ARRAY(Float(precision=53)))
models = relationship('Model', back_populates='feature_vectors')
class Model(SQLAlchemyObjectType):
class Meta:
model = ModelModel
interfaces = (relay.Node, )
class ModelConn(relay.Connection):
class Meta:
node = Model
class Query(graphene.ObjectType):
node = relay.Node.Field(schema_cadlearn.Model)
all_models = SQLAlchemyConnectionField(ModelConn)