Multiple Filters On Express-GraphQL
<p>I'm using express-graphql and node-fetch in my application. I am trying to use graphql with my api call to grab data. Currently I am doing </p>

<pre><code>const QueryType = new GraphQLObjectType({
  name: "Query",
  fields: () =&gt; ({
    acctsFromRelation: {
      type: new GraphQLList(AcctType),
      args: {
       id: {type: GraphQLString},
       status: {type: GraphQLString}
      },
      resolve: (root, args) =&gt; getOpIds(args)
    }
  })
});
</code></pre>

<p>The AcctType is as follows</p>

<pre><code> const AcctType = new GraphQLObjectType({
  name: "acct",
  fields: () =&gt; ({
    id: {type: GraphQLString},
    name: {type: GraphQLString},
    clientType: {type: GraphQLString},
    accountStatus: {type: GraphQLString,
    args: {
      status: {type: GraphQLString}
    }},
    primaryContact: {type: contactType},
    billingAddress: {type: billingType}
  })
});
</code></pre>

<p>I'm trying to do something like this:</p>

<pre><code>{ acctsFromRelation (id: "2") {
  id
  name
  accountStatus (status: "active")
  primaryContact {
    firstName
    lastName
    phone
    email
  }
  billingAddress {
    address1
    address2
    city
    state
    postalCode
    country
  }
}
}
</code></pre>

<p>where i obtain all accounts with id of 2 and accountStatus of active.</p>

<p>GetOpIds is as follows:</p>

<pre><code>function getOpIds (ids) {
  return fetch(API CALL THAT GIVES IDS)
    .then(res =&gt; res.json())
    .then(json =&gt; json.map((element) =&gt; getAccountByUrl(element.id)))
    .catch(err =&gt; err)
}
</code></pre>

<p>and getAccountByUrl looks like this</p>

<pre><code>function getAccountByUrl (ids) {
  return fetch(URL THAT LOOKS UP 1 ID at a TIME)
    .then(res =&gt; res.json())
    .then(json =&gt; json)
    .catch(err =&gt; err)
}
</code></pre>