我如何使用逻辑运算符与Stradi的graphql过滤

时间:2019-08-01 22:13:34

标签: graphql strapi

我正在像这样传递graphql变量:

private Handler mRepeatHandler;
private Runnable mRepeatRunnable;
private final static int UPDATE_INTERVAL = 2000;
@Override
protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);

     mRepeatHandler = new Handler();
     mRepeatRunnable = new Runnable() {
          @Override
          public void run() {
               //Put the piece of code which is getting data from server.

               mRepeatHandler.postDelayed(mRepeatRunnable, UPDATE_INTERVAL);
          };

     mRepeatHandler.postDelayed(mRepeatRunnable, UPDATE_INTERVAL);
}

我希望联盟名称或球队名称或两者同时存在。 但是我当前的配置设置为同时存在联盟名称和球队名称

查询如下:

bool_mask = (df['a'] == 'aaa') & \
            (df['b'] == '') & \
            (df['c'] == '') & \
            (df['d'] == '') & \
            (df['e'] == '') & \
            (df['f'] == '') & \
            (df['m'] == '') & \
            (df['n'] == '') & \
            (df['w'] == '')

df = df[~bool_mask]

1 个答案:

答案 0 :(得分:0)

我想您正在寻找howtographql documentation中的某样东西,目前我在stradi文档中看不到类似的解决方案,但是我还有其他解决方法...

teams.name && League.name

您只需要这些参数

where:{teams: {name_contains: "some league name"}, league: {name_contains: "some league name"}}

teams.name || League.name

在这种情况下,您需要像这样为每个父名称合并单独的查询:

where:{teams: {name_contains: "some league name"}}

where:{league: {name_contains: "some league name"}}

身体变换功能:

const gameMap = [...teamsGames, ...leagueGames].reduce((games, game) => {
  games[game.id] = games[game.id] ? games[game.id] : { id: game.id, teams: [], league: [] };
  games[game.id].teams = [...games[game.id].teams, ...game.teams];
  games[game.id].league = [...games[game.id].league, ...game.league];

  return games;
}, {});

//flat to array
Object.keys(gameMap).map(key => gameMap[key]);