(solved) Yargh! Cell runtime error && Error: Could not generate GraphQL type definitions (web)

I’m getting a cell runtime error

the cell is thus:

import type {
  FindConvertWordToPdfQuery,
  FindConvertWordToPdfQueryVariables,
} from 'types/graphql'

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

export const QUERY = gql`
  query FindConvertWordToPdfQuery($id: Int!) {
    convertWordToPdf: convertWordToPdf(id: $id) {
      id
      name
    }
  }
`

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

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

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

export const Success = ({
  convertWordToPdf,
}: CellSuccessProps<
  FindConvertWordToPdfQuery,
  FindConvertWordToPdfQueryVariables
>) => {
  return <div>{JSON.stringify(convertWordToPdf)}</div>
}

The service is thus:

import type { QueryResolvers, MutationResolvers } from 'types/graphql'

import { db } from 'src/lib/db'

export const convertWordToPdf: QueryResolvers['convertWordToPdf'] = () => {
  return db.convertWordToPdf.findMany()
}

export const convertWordToPdf: QueryResolvers['convertWordToPdf'] = ({
  id,
}) => {
  return db.convertWordToPdf.findUnique({
    where: { id },
  })
}

export const createConvertWordToPdf: MutationResolvers['createConvertWordToPdf'] =
  ({ input }) => {
    return db.convertWordToPdf.create({
      data: input,
    })
  }

export const updateConvertWordToPdf: MutationResolvers['updateConvertWordToPdf'] =
  ({ id, input }) => {
    return db.convertWordToPdf.update({
      data: input,
      where: { id },
    })
  }

export const deleteConvertWordToPdf: MutationResolvers['deleteConvertWordToPdf'] =
  ({ id }) => {
    return db.convertWordToPdf.delete({
      where: { id },
    })
  }

and when I execute
yarn rw-gen it errors

Generating...

- .redwood/schema.graphql
- .redwood/types/mirror/api/src/directives/requireAuth/index.d.ts
- .redwood/types/mirror/api/src/directives/skipAuth/index.d.ts
- .redwood/types/mirror/api/src/services/convertWordToPdf/index.d.ts
- .redwood/types/mirror/web/src/components/WebViewerFrame/index.d.ts
- .redwood/types/mirror/web/src/pages/AccountPage/index.d.ts
- .redwood/types/mirror/web/src/pages/ConvertWordToPdfPage/index.d.ts
- .redwood/types/mirror/web/src/pages/FatalErrorPage/index.d.ts
- .redwood/types/mirror/web/src/pages/ForgotPasswordPage/index.d.ts
- .redwood/types/mirror/web/src/pages/HomePage/index.d.ts
- .redwood/types/mirror/web/src/pages/LoginPage/index.d.ts
- .redwood/types/mirror/web/src/pages/NotFoundPage/index.d.ts
- .redwood/types/mirror/web/src/pages/ResetPasswordPage/index.d.ts
- .redwood/types/mirror/web/src/pages/SignupPage/index.d.ts
- .redwood/types/mirror/web/src/pages/WebInterviewPage/index.d.ts
- .redwood/types/mirror/web/src/pages/WebReviewPage/index.d.ts
- .redwood/types/mirror/web/src/components/ConvertWordToPdfCell/index.d.ts
- .redwood/types/includes/web-routesPages.d.ts
- .redwood/types/includes/all-currentUser.d.ts
- .redwood/types/includes/web-routerRoutes.d.ts
- .redwood/types/includes/api-globImports.d.ts
- .redwood/types/includes/api-globalContext.d.ts
- .redwood/types/includes/api-scenarios.d.ts
- .redwood/types/includes/api-test-globals.d.ts
- .redwood/types/includes/web-test-globals.d.ts
- .redwood/types/includes/web-storybook.d.ts
- api/types/graphql.d.ts

... done with errors.

Error: Could not generate GraphQL type definitions (web)

Error: GraphQL Document Validation failed with 2 errors;
  Error 0: Unknown type "Int".
    at /Users/ajoslin/Development/ResearchCircle/Round4/apryse-poc/web/src/components/ConvertWordToPdfCell/ConvertWordToPdfCell.tsx:1:38

Error 1: Cannot query field "convertWordToPdf" on type "Query".
    at /Users/ajoslin/Development/ResearchCircle/Round4/apryse-poc/web/src/components/ConvertWordToPdfCell/ConvertWordToPdfCell.tsx:2:3
    at codegen (/Users/ajoslin/Development/ResearchCircle/Round4/apryse-poc/node_modules/@graphql-codegen/core/cjs/codegen.js:83:19)
    at async runCodegenGraphQL (/Users/ajoslin/Development/ResearchCircle/Round4/apryse-poc/node_modules/@redwoodjs/internal/dist/generate/graphqlCodeGen.js:164:18)
    at async generateTypeDefGraphQLWeb (/Users/ajoslin/Development/ResearchCircle/Round4/apryse-poc/node_modules/@redwoodjs/internal/dist/generate/graphqlCodeGen.js:131:21)
    at async generateTypeDefs (/Users/ajoslin/Development/ResearchCircle/Round4/apryse-poc/node_modules/@redwoodjs/internal/dist/generate/typeDefinitions.js:59:7)
    at async generate (/Users/ajoslin/Development/ResearchCircle/Round4/apryse-poc/node_modules/@redwoodjs/internal/dist/generate/generate.js:24:7)
    at async run (/Users/ajoslin/Development/ResearchCircle/Round4/apryse-poc/node_modules/@redwoodjs/internal/dist/generate/generate.js:42:7)

I have alse yarn rw g types to no avail… (same err as yarn rw-gen)

Thanks for any Help

Al;

What’s in the convertWordToPdf.sdl.ts file?

Hello Tony,

So glad to meet you !!

I’m just an old hack from way back – so I continually have to unlearn old stuff – and I forget !!

After a bit of mucking about – I’ve fixed the problem by deleting the results of

yarn rw g cell convert-word-to-pdf && yarn rw g service convert-word-to-pdf

and replacing them with

yarn rw g cell convert-word-to-pdf && yarn rw g sdl convert-word-to-pdf

So I think your question would have been spot on – I bet there was not an .sdl file before

Cheers!

Al;

1 Like