I'm using Pothos to build a graphql schema and graphql-codegen to generate types based on this schema. The server runs via graphql-yoga and nextjs and the actual query works fine when run via the graphiql interface. I've been trying to set this up so my gql schema is typed properly with apollo client based on this article.
Snipped of the schema builder:
builder.queryType({
fields: t => ({
greetings: t.string({
resolve: (root, args, context) => `Welcome ${context.session?.user?.nickname}`
})
})
})
graphql-codegen generates the following type in the written .ts
file so I know it's seeing the right schema.
export type Query = {
__typename?: 'Query';
greetings: Scalars['String'];
}
However, when I import the gql file per the codegen docs, it returns unknown
and VSCode's hover window says "The query argument is unknown! Please regenerate the types." I've tried regenerating and rebooting VSCode and nothing changes.
import { gql } from '@/gql/gql'
const query = gql('query { greetings }')