Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Relationship query error after update

default discord avatar
akacronos2 years ago

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,},
    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get dedicated engineering support directly from the Payload team.