[英]How to filter data in GraphQL query in Flutter?
我在 Flutter 中使用 GraphQL。 我在 Flutter 中使用 GraphQL 的經驗並不多。 代碼如下:
WidgetsFlutterBinding.ensureInitialized();
final HttpLink link = HttpLink(
uri: 'https://api.spacex.land/graphql/',
);
ValueNotifier<GraphQLClient> client = ValueNotifier(
GraphQLClient(
cache: InMemoryCache(),
link: link,
),
);
runApp(MyApp(client: client));
}
我必須通過此公共后端公開的“mission_name”字段調用 GraphQL 查詢“launches”過濾來執行: https ://api.spacex.land/graphql/。 但我不知道該怎么做。 如果有人知道該怎么做,請幫助我。 謝謝
您必須通過使用 api 特定關鍵字進行過濾來進行過濾。 在https://api.spacex.land/graphql/ 的情況下,它是find關鍵字,對於其他 api,它可能是where或filter下面是通過調用GraphQL查詢“launches”按“mission_name”過濾完成的搜索示例. 舉個例子,我把“mission_name” = "Thaicom 6" ,你可以根據你的要求編輯它。
query launchesDetails {
launches(find: {
mission_name: "Thaicom 6",
}) {
details
id
is_tentative
launch_date_local
launch_date_unix
launch_date_utc
launch_site {
site_id
site_name
}
launch_success
launch_year
mission_name
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.