# GraphQL access fields

**URL:** <https://community.appfarm.io/t/graphql-access-fields/1065>\
**Category:** Ask the community\
**Created:** [February 21, 2024, 10:23am UTC](https://community.appfarm.io/t/graphql-access-fields/1065 "2024-02-21T10:23:03Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![SinanMaric](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/sinanmaric/32/1226_2.png) [@SinanMaric](https://community.appfarm.io/u/SinanMaric)\
**Post date:** [February 21, 2024, 10:23am UTC](https://community.appfarm.io/t/graphql-access-fields/1065/1 "2024-02-21T10:23:04Z")

</div>

Hi, testing out GraphQL in Appfarm. Based on GraphQL documentation, you can do the following to fetch data with string matching.

```auto
query companyByName{
  company(name: "hei") {
    name
  }
}

```

However, as you can see from the first screen shot, this does not work. And the reason for that is because as you can see from the Company constructor in the GraphQL IDE for Appfarm, only sort, filter, skip and limit are fields in the constructor.

 ![Screenshot 2024-02-21 at 11.17.06](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/8/8d14a7ed7312bfcb8c0b94120d17f800593886dc.png)

The question then is how I can access the actual fields of the Company object? As you can see from the screenshot below. If I access the type Company. I get the real fields. How can I access these in the query?

 ![Screenshot 2024-02-21 at 11.17.29](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/0/0a0d332a1d84d134b2e0b6cb7af9405e0c9dea6e.png)

---

<div class="post-metadata">

**Author:** ![SinanMaric](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/sinanmaric/32/1226_2.png) [@SinanMaric](https://community.appfarm.io/u/SinanMaric)\
**Post date:** [February 21, 2024, 10:33am UTC](https://community.appfarm.io/t/graphql-access-fields/1065/2 "2024-02-21T10:33:38Z")

</div>

I found the solution:

```auto
query {
  company(
    filter: {
      name: {
        eq: "Oslo"
      }
    }
  ) {
    name
  }
}

```

This works. However is there a simpler way of doing this, just by accessing name directly from the compan object?

---

<div class="post-metadata">

**Author:** ![kristian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/kristian/32/58_2.png) [@kristian](https://community.appfarm.io/u/kristian)\
**Post date:** [February 21, 2024, 11:11am UTC](https://community.appfarm.io/t/graphql-access-fields/1065/3 "2024-02-21T11:11:30Z")

</div>

Hi!

That solution is correct. The only way to [query data using GraphQL](https://docs.appfarm.io/reference/data-model/graphql/queries) is to apply a filter to to query. Filters have more power than the parameter-filtering you suggest, but they have a bit more syntax.

---

<div class="post-metadata">

**Author:** ![SinanMaric](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/sinanmaric/32/1226_2.png) [@SinanMaric](https://community.appfarm.io/u/SinanMaric)\
**Post date:** [April 24, 2024, 12:21pm UTC](https://community.appfarm.io/t/graphql-access-fields/1065/4 "2024-04-24T12:21:39Z")

</div>

I have another question @kristian .

I have the following query:

```auto
{
  Product: product(limit: 5, sort: {af_createdDate: DESC}, filter: {accountingID: {ne: null}}) {
    ProductNumber: productNumber
    ProductOwner: productOwner_reference {
      ProductOwnerName: name
      Company: company_reference {
        CompanyName: name
        ClientID: client  
      }
    }
  }
}

```

We want to fetch Product for ClientID eq “XYZ”. However, company\_reference does not have a filter-attribute, so it is impossible to filter. How should we do it?

---

<div class="post-metadata">

**Author:** ![jeremy.jean](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/jeremy.jean/32/123_2.png) [@jeremy.jean](https://community.appfarm.io/u/jeremy.jean)\
**Post date:** [April 24, 2024, 1:20pm UTC](https://community.appfarm.io/t/graphql-access-fields/1065/5 "2024-04-24T13:20:40Z")

</div>

Hi,  
I’m facing this kind of challenge quite often. In order to achieve, this, I’m using a two step query:

- First query the client object class with name: {eq: “XYZ”} and only retrieve the \_id
- Query the product object class with filtre on the clientID

But, if there’s an other way of doing this, i’ll be glad to hear

---

<div class="post-metadata">

**Author:** ![Amit](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/amit/32/1254_2.png) [@Amit](https://community.appfarm.io/u/Amit)\
**Post date:** [April 24, 2024, 1:36pm UTC](https://community.appfarm.io/t/graphql-access-fields/1065/6 "2024-04-24T13:36:43Z")

</div>

Hi Jeremy.jean, we will wait to get suitable response as we are trying to do it in a single query. Also, note that it is at three levels Product - Owner - Company. Thank you for your inputs.

---

<div class="post-metadata">

**Author:** ![jeremy.jean](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/jeremy.jean/32/123_2.png) [@jeremy.jean](https://community.appfarm.io/u/jeremy.jean)\
**Post date:** [April 25, 2024, 7:52am UTC](https://community.appfarm.io/t/graphql-access-fields/1065/7 "2024-04-25T07:52:32Z")

</div>

Hi,  
When looking at the documentation of GraphQL queries (on the right side in GraphiQL), you can only filter on object class of the first level, so as far as I understand it, it’s just not possible (or not yet) to do that in a single query. But maybe someone from Appfarm can confirm or give insights about this feature request?

---

<div class="post-metadata">

**Author:** ![Amit](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/amit/32/1254_2.png) [@Amit](https://community.appfarm.io/u/Amit)\
**Post date:** [April 25, 2024, 9:34am UTC](https://community.appfarm.io/t/graphql-access-fields/1065/8 "2024-04-25T09:34:25Z")

</div>

It seems to be the case with AppFarm GraphQL implementation. But in general we should be able to define “resolver” to fetch any data. Let us wait for AppFarm response.

---

<div class="post-metadata">

**Author:** ![SinanMaric](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/sinanmaric/32/1226_2.png) [@SinanMaric](https://community.appfarm.io/u/SinanMaric)\
**Post date:** [April 29, 2024, 1:48pm UTC](https://community.appfarm.io/t/graphql-access-fields/1065/9 "2024-04-29T13:48:42Z")

</div>

Hi, @kristian or someone else from Appfarm. Do you have any solutions for [GraphQL access fields - #4 by SinanMaric](https://community.appfarm.io/t/graphql-access-fields/1065/4)? Thank you 🙂

---

<div class="post-metadata">

**Author:** ![kristian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/kristian/32/58_2.png) [@kristian](https://community.appfarm.io/u/kristian)\
**Post date:** [April 29, 2024, 2:03pm UTC](https://community.appfarm.io/t/graphql-access-fields/1065/10 "2024-04-29T14:03:07Z")

</div>

Hi!

There is currently (and not in near-future) no possibilities for filtering sub-entities (such as in SQL where you may use exists in with some sub-query).

What is the use case, is it just for data exploration, og for using grapghQL as a way of integration? If the last one is the case, you may solve it using a Service Endpoint instead.

---

<div class="post-metadata">

**Author:** ![kristian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/kristian/32/58_2.png) [@kristian](https://community.appfarm.io/u/kristian)\
**Post date:** [April 29, 2024, 2:31pm UTC](https://community.appfarm.io/t/graphql-access-fields/1065/11 "2024-04-29T14:31:00Z")

</div>

By the way: could you instead query Company, with Filter, and then list project\_list per Company?

---

<div class="post-metadata">

**Author:** ![Amit](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/amit/32/1254_2.png) [@Amit](https://community.appfarm.io/u/Amit)\
**Post date:** [April 29, 2024, 3:23pm UTC](https://community.appfarm.io/t/graphql-access-fields/1065/12 "2024-04-29T15:23:44Z")

</div>

Hi @kristian, Use case is Integration and we want to send all related data via single query just like in case of SQL as you mentioned. Now that we have answer from you, we have already implemented multi query within Service Endpoint and that is got exposed to client for integration.
