Noob question - why are there 3 GraphQL calls issued in a generated Cell that lists objects?

So, I noticed this as well earlier when developing an envelop plugin, that refreshing the page one time in a cell generated with yarn rw g cell X with the default query actually triggers the resolver lifecycle for the Query.x call 3 times.

I just installed opentracing for GraphQL via the Open Telemetry envelop plugin: useOpenTelemetry | Envelop Plugin Hub

This trace is generated:

The query is defined in the cell as:

export const QUERY = gql`
  query FindApplicants {
    applicants {
      id
      updatedAt
      firstName
      middleInitial
      lastName
      dob
      ssn
    }
  }
`

So it appears that FindApplicants actually invokes the Query.applicants 3 times to generate this result. Why does this happen?

Would you be able show the source of the page that contains the Cell ?

Thanks!

import type { FindApplicants } from 'types/graphql'
import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web'

import { Link, routes } from '@redwoodjs/router'

import Applicants from 'src/components/Applicant/Applicants'

export const QUERY = gql`
  query FindApplicants {
    applicants {
      id
      updatedAt
      firstName
      middleInitial
      lastName
      dob
      ssn
    }
  }
`

export const Loading = () => <div>Loading...</div>

export const Empty = () => {
  return (
    <div className="rw-text-center">
      {'No applicants yet. '}
      <Link
        to={routes.newApplicant()}
        className="rw-link"
      >
        {'Create one?'}
      </Link>
    </div>
  )
}

export const Failure = ({ error }: CellFailureProps) => (
  <div className="rw-cell-error">{error.message}</div>
)

export const Success = ({ applicants }: CellSuccessProps<FindApplicants>) => {
  return <Applicants applicants={applicants} />
}


And where is the cell component used?

Hi @twodotsmax.

This is curious and we had seen two request in the past sever many release ago, but never three.

Few questions:

  • In your API log with GraphQL logging and Prisma logging turned on, do you see the resolver being executed three times?
  • Is your query behind an auth directive?
  • Is your page or cell behind auth (aka a private route)?
  • Is this an n+1 query? Is the find many applicants also calling three get applicants? (maybe?)

Does the number of queries match the number of applicants return – if you add an applicant does telemetry report 4 queries and not three?

I’d like to see if the Redwood API/GraphQL server is making three calls, to perhaps the openTelementy is sending several? Maybe for different lifecycle events (though should be in a single execution).