graphql codegen defaults to watchQuery, no possible way to alter? I only want to get the value 1 time

graphql codegen defaults to watchQuery, no possible way to alter? I only want to get the value 1 time


1

I have a sveltekit + apollo graphql project here. introspecting from my dev-env api here.

The issue I’m having is the codegen with this config:

import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
    schema: '<<<url>>>',
    documents: './src/lib/graphql-service/**/*.gql',
    generates: {
        './src/lib/graphql-service/generated.ts': {
            plugins: ['typescript', 'typescript-operations', 'graphql-codegen-svelte-apollo']
        }
    },
    watch: false
};
export default config;

is only generating watchQuery type of queries.

Example of generated query:

export const Me = (
    options: Omit<WatchQueryOptions<MeQueryVariables>, 'query'>
): Readable<
    ApolloQueryResult<MeQuery> & {
        query: ObservableQuery<MeQuery, MeQueryVariables>;
    }
> => {
    const q = client.watchQuery({
        query: MeDoc,
        ...options
    });
    var result = readable<
        ApolloQueryResult<MeQuery> & {
            query: ObservableQuery<MeQuery, MeQueryVariables>;
        }
    >({ data: {} as any, loading: true, error: undefined, networkStatus: 1, query: q }, (set) => {
        q.subscribe((v: any) => {
            set({ ...v, query: q });
        });
    });
    return result;

I can’t seem to find anything around the docs or example projects around how this whole thing could be altered, if at all?

Share


Load 4 more related questions


Show fewer related questions

0

Reset to default



Browse other questions tagged

or ask your own question.

Leave a Reply

Your email address will not be published. Required fields are marked *