Relationship query error after update

default discord avatar
akacronos
4 months ago
6

Yesterday I updated Payload and started getting an error when doing a query.


{"errors":[{"name":"QueryError","message":"The following path cannot be queried: call","data":[{"path":"call"}]}]}

This is the query:


import axios from 'axios';

const getCallSubmission = async ({ userId, callId }) => {
  const params = {
    where: {
      and: [
        {
          user: {
            equals: userId,
          },
        },
        {
          call: {
            equals: {
              value: callId,
              relationTo: 'activities',
            },
          },
        },
      ],
    },
  };

  const { data } = await axios.get('/payload/callsFormsSubmissions', {
    params,
  });
  return data;
};

export default getCallSubmission;


The collection is a formSubmisions collection from the formBuilder plugin:


formSubmissionOverrides: {
        slug: 'callsFormsSubmissions',
        labels: {
          singular: 'InscripciĆ³n a convocatoria',
          plural: 'Inscripciones a convocatorias',
        },
        access: {
          create: () => true,
          read: () => true,
          update: isNotEditor,
          delete: isNotEditor,
        },
        fields: [
          {
            name: 'user',
            type: 'relationship',
            label: 'Usuario',
            relationTo: 'users',
            required: true,
            index: true,
          },
          {
            name: 'call',
            type: 'relationship',
            label: 'Convocatoria',
            relationTo: ['activities'],
            required: true,
            index: true,
          },
        ],
        admin: {
          group: 'Config',
        },
      },


I stop getting Submissions since yesterday



I found that all my queries that use a relationship query stop working!



Relationship query error after update



I changed my query to this:



import qs from 'qs';
import axios from 'axios';

const getCallSubmission = async ({ callId, userId }) => {
  const query = {
    where: {
      and: [
        {
          user: {
            equals: userId,
          },
        },
        {
          call: {
            equals: {
              value: callId,
              relationTo: 'activities',
            },
          },
        },
      ],
    },
  };

  const stringifiedQuery = qs.stringify(
    {
      query,
    },
    { addQueryPrefix: true },
  );

  const { data } = await axios.get(
    `/payload/callsFormsSubmissions${stringifiedQuery}`,
  );
  return data;
};

export default getCallSubmission;


Now i get data, but it's all the docs, not the specific that matches the and logic :/



I make it work changing:


{
  call: {
    equals: {
      value: callId,
      relationTo: 'activities',
    },
  },
 },


To:

{'call.value': { equals: callId,},
    Open the post
    Continue the discussion in Discord
    Like what we're doing?
    Star us on GitHub!

    Star

    Connect with the Payload Community on Discord

    Discord

    online

    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.