How do i fix the error "unknown type "queryName" " on redwood js?

Using redwood JS framework, i’m trying to make queries to the database using graphQL. problem is that i get an error when i try to generate types :

Error 0: Unknown type “FindEditEventQueryVariables”. at /home/alaborde/lisaquapp/app/web/src/components/EditEventCell/EditEventCell.tsx:1:47

it’s crazy because i want to generate type for that BUT it doesn’t wan’t to generate because the type doesn’t exist. it’s an infinite loop. what should i do ?

i’m kinda new to the web dev world and i don’t know a lot about queries.

Here’s the code i wrote for this cell :

import type {
  FindEventListQuery,
  FindEventListQueryVariables,
} from 'types/graphql'
import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web'
import EventList from '../EventList/EventList'

export const QUERY = gql`
  query FindEventListQuery($id: Int!) {
    event: event(typeId: $id) {
      id
      description
      criticalityId
      typeId
      idTank
      idWater
      idBatch
      createdAt
      createdBy
    }
  }
`

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

export const Empty = () => <div>Empty</div>

export const Failure = ({
  error,
}: CellFailureProps<FindEventListQueryVariables>) => (
  <div style={{ color: 'red' }}>Error: {error?.message}</div>
)

export const Success = ({
  event,
}: CellSuccessProps<FindEventListQuery, FindEventListQueryVariables>) => {
  return (
    <EventList eventsList={event}/>
  )
}

i’ll quickly explain what i want to achieve with this query :

I want to get all events which have the same TankId.

Any idea on what to do here ?

EDIT : In fact, i have the type generated. when i go check the source of the import with vscode, the type is generated whereas the type generator still give me the same error. Another thing, some type are shown with “error” in vscode but in the generator it’s good, they’re generated. i’m so confused

1 Like

Hi @alaborde29 could you see if I see red squiggles - How to fix type warnings in VS Code helps with the errors you see? Sometimes it’s VSCode not auto refreshing it’s knowledge of types.