Getting duplicate column_values in Board query with groups

Hello :wave:

Currently trying to pull out some workflow data for a mini dashboard with tasks/statuses/assignees etc.
Query here:

query Boards($ids: [Int]) {
  me {
    name
  }
  
  boards(ids: $ids) {
    name
    
    columns {
      title
      id
      type
    }
    
    groups {
    	title
      id
    }
    
    items {
      name
      group {
        id
      }
      
      column_values {
        id
        value
        text
      }
    }
  }
}

Weirdly, the data that comes back both in the Monday Playground and in my local Insomnia calls is correct, but in my Next/Apollo app the data for the column_values is all the same as the first column_value entry, depending whichever item comes first in the call…
Can’t for the life of me work out what is going on, but the difference between local logging (straight from the query response) in node and the local Insomnia response seems odd…?
Have checked for Apollo caching weirdness but it’s serverside and the simplest call possible, so one would think should align with what Insomnia gets back.

Any help would be much appreciated, and let me know if any further info needed - thanks!

Brad

Hey Brad, sounds strange.

As far as I understand, you’re trying to return column values but you’re getting the same value for every column, right?

Can you share some output from your app so we can see an example?

Cheers,
Dipro

Hey Dipro,

Sure thing. I’ve since found out also that the output changes depending on whether I request the column_values.id or not - with the id field in the request, I get back the incorrect, repeated first value data, whereas without it I get the correct stuff.

Here is the output for the first 2 items in boards[0].items, firstly with the id in the request:

{
  __typename: 'Item',
  name: 'List of staff',
  group: {
    __typename: 'Group',
    id: 'new_group123',
    title: 'Staff rostering'
  },
  column_values: [
    {
      __typename: 'ColumnValue',
      id: 'subitems',
      value: null,
      text: ''
    },
    {
      __typename: 'ColumnValue',
      id: 'person',
      value: '{"changed_at":"2021-12-21T10:55:16.798Z","personsAndTeams":[{"id":12345678,"kind":"person"}]}',
      text: 'Brian'
    },
    {
      __typename: 'ColumnValue',
      id: 'status0',
      value: '{"index":4,"post_id":null,"changed_at":"2021-11-22T13:04:53.044Z"}',
      text: 'Medium'
    },
    {
      __typename: 'ColumnValue',
      id: 'status',
      value: '{"index":1,"post_id":null,"changed_at":"2021-11-22T13:04:54.962Z"}',
      text: 'Done'
    },
    {
      __typename: 'ColumnValue',
      id: 'date',
      value: '{"date":"2021-12-14","changed_at":"2021-12-14T14:25:27.274Z"}',
      text: '2021-12-14'
    },
    { __typename: 'ColumnValue', id: 'numbers', value: null, text: '' },
    { __typename: 'ColumnValue', id: 'files', value: null, text: '' },
    {
      __typename: 'ColumnValue',
      id: 'progress_tracking',
      value: null,
      text: ''
    }
  ]
}
{
  __typename: 'Item',
  name: 'Set up to be completed',
  group: {
    __typename: 'Group',
    id: 'new_group123',
    title: 'Staff rostering'
  },
  column_values: [
    {
      __typename: 'ColumnValue',
      id: 'subitems',
      value: null,
      text: ''
    },
    {
      __typename: 'ColumnValue',
      id: 'person',
      value: '{"changed_at":"2021-12-21T10:55:16.798Z","personsAndTeams":[{"id":12345678,"kind":"person"}]}',
      text: 'Brian'
    },
    {
      __typename: 'ColumnValue',
      id: 'status0',
      value: '{"index":4,"post_id":null,"changed_at":"2021-11-22T13:04:53.044Z"}',
      text: 'Medium'
    },
    {
      __typename: 'ColumnValue',
      id: 'status',
      value: '{"index":1,"post_id":null,"changed_at":"2021-11-22T13:04:54.962Z"}',
      text: 'Done'
    },
    {
      __typename: 'ColumnValue',
      id: 'date',
      value: '{"date":"2021-12-14","changed_at":"2021-12-14T14:25:27.274Z"}',
      text: '2021-12-14'
    },
    { __typename: 'ColumnValue', id: 'numbers', value: null, text: '' },
    { __typename: 'ColumnValue', id: 'files', value: null, text: '' },
    {
      __typename: 'ColumnValue',
      id: 'progress_tracking',
      value: null,
      text: ''
    }
  ]
}

And then without the id field:

{
  __typename: 'Item',
  name: 'List of staff created',
  group: {
    __typename: 'Group',
    id: 'new_group123',
    title: 'Staff rostering'
  },
  column_values: [
    { __typename: 'ColumnValue', value: null, text: '' },
    {
      __typename: 'ColumnValue',
      value: '{"changed_at":"2021-12-21T10:55:21.978Z","personsAndTeams":[{"id":12345678,"kind":"person"}]}',
      text: 'Brian'
    },
    {
      __typename: 'ColumnValue',
      value: '{"index":4,"post_id":null,"changed_at":"2021-11-22T13:04:57.856Z"}',
      text: 'Medium'
    },
    {
      __typename: 'ColumnValue',
      value: '{"index":1,"post_id":null,"changed_at":"2021-11-22T13:04:59.798Z"}',
      text: 'Done'
    },
    {
      __typename: 'ColumnValue',
      value: '{"date":"2021-12-28","changed_at":"2021-12-14T14:25:30.134Z"}',
      text: '2021-12-28'
    },
    { __typename: 'ColumnValue', value: null, text: '' },
    { __typename: 'ColumnValue', value: null, text: '' },
    { __typename: 'ColumnValue', value: null, text: '' }
  ]
}
{
  __typename: 'Item',
  name: 'Set up to be completed on Teamnet including resource booking',
  group: {
    __typename: 'Group',
    id: 'new_group123',
    title: 'Staff rostering'
  },
  column_values: [
    { __typename: 'ColumnValue', value: null, text: '' },
    {
      __typename: 'ColumnValue',
      value: '{"changed_at":"2021-12-21T10:55:27.420Z","personsAndTeams":[{"id":12345678,"kind":"person"}]}',
      text: 'Brian'
    },
    {
      __typename: 'ColumnValue',
      value: '{"index":2,"post_id":null,"changed_at":"2021-11-22T13:05:08.208Z"}',
      text: 'High'
    },
    {
      __typename: 'ColumnValue',
      value: '{"index":1,"post_id":null,"changed_at":"2021-12-03T15:46:10.576Z"}',
      text: 'Done'
    },
    { __typename: 'ColumnValue', value: null, text: '' },
    { __typename: 'ColumnValue', value: null, text: '' },
    { __typename: 'ColumnValue', value: null, text: '' },
    { __typename: 'ColumnValue', value: null, text: '' }
  ]
}

Probs 2 big blocks of response there, but basically the ColumnValues for the two items should have (anonymised):

  • Person: Brian, Priority: Medium, Status: Done
  • Person: Brian, Priority: High, Status: Done

which they do, but only from the query with no id field.

Hope that makes sense! I’ll see if I can spin up a minimal repro for it for you to check too.

B

Minimal reproduction repo here :blush:

Still exhibits same behaviour, so if you uncomment/comment the id field for column_values in the GQL query in index.ts it should (for me at least) return different data in the console…

Usual Next.js starter project:

  • pull repo
  • add API token into .env
  • add in a board_id of yours into the variable above the query
  • yarn install && yarn dev

Let me know what you get if you have a mo to try it out… :+1: thanks!

Thanks for sharing that repo. Weirdly, I couldn’t reproduce this behaviour on my side. I’m curious if it’s specific to that board or there’s something in your production code that changes the results.

I think we should resolve this over a call, so we can see the behaviour in action and troubleshoot on the fly. Here’s a link to sign up for a session with our team: Developer Success Office Hours

Hello,

I have the exact same problem. It is quite blocking for me as I need to check unicity of some values in a column. But the data I get returns the same value for each record, even if in the dashboard I clearly see that each record has a different value for this column.

I scheduled a session with the developer success team.

Hey @jesmodrazik, I had a call with Matias from the DST too so has been passed on to the R&D team for a look - have you had any luck finding a solution/reason for this in the meantime?

Just gave it another shot, it seems it has been fixed?

@jesmodrazik that’s odd, had you changed your code at all?

I have managed to figure out what was going on with mine this evening, finally… it was a very awkward, but oddly simple, bug with Apollo - basically that in the column_values edge(s), the array contained id's of the columns, which were being used by Apollo in the internal in-memory caching (separate to the overall caching of results) when the query is returned, and so couldn’t tell that they should be different.

Adding the following snippet into the cache option in my apollo-client.ts allows the correct results through from the query, thanks to this Stack Overflow answer :joy:

const client = new ApolloClient({
  uri: "https://api.monday.com/v2",
  headers: {
    "Content-Type": "application/json",
    Authorization: process.env.MONDAY_API_TOKEN || "",
  },
  cache: new InMemoryCache({
    dataIdFromObject: (o) => (o._id ? `${o.__typename}:${o._id}` : undefined),
  }),
});

Hopefully if anyone else has a similar issue from the get-go with a v simple Apollo + Monday situation, this might save them a week or so of intermittent head-scratching…

Yeah I switched from @apollo/client to urql in the meantine (mainly for bundle size reasons). The problem seems to be on the Apollo side then.