【发布时间】:2017-05-28 16:19:43
【问题描述】:
我正在尝试在 Meteor blaze 项目中使用 Apollo graphql。
我正在使用来自swydo:blaze-apollo 的包。
可以使用graphql查询从mongoDB获取数据。
// Using this one can get data
const LOCATION_COUNTRY_QUERY = gql`
{
locations(location_type: "Country"){
location_id
name
iso_code
}
}
`;
Template.home.onCreated(function(){
const country = this.gqlQuery({query: LOCATION_COUNTRY_QUERY}).get();
console.log(country.locations); // Which will show an array list of country.
});
但是,我不想在查询中硬编码“国家/地区”。我想将字符串传递到查询中,然后使用其他 location_type 获取数据。但我找不到任何关于它的文章,而且 gql 语法只是阻止了任何参数。
谁有类似的经历,可以给点建议吗?
【问题讨论】:
标签: meteor meteor-blaze graphql apollo