Tag: graphql-codegen
-
Types conflict when using GraphQL Code generator (codegen)
1 given the following codegen.ts import type { CodegenConfig } from ‘@graphql-codegen/cli’; const config: CodegenConfig = { overwrite: true, schema: ‘https://mySchema’, documents: ‘src/**/*.ts’, generates: { ‘src/apollo/gql/’: { preset: ‘client’, plugins: [] } } }; export default config; the types generated starting from my schema.json are in conflict. I have a query with the following request:…
-
What plugin should I use to generate types for a server-side only library?
0 I have a working codegen.yml example using: src/generated/graphql.tsx: plugins: – typescript – typescript-operations – typescript-react-apollo that works great for our front end code making a tsx final result used with react. Over in my other project: src/generated.ts: plugins: – "typescript" – "typescript-operations" – "typescript-document-nodes" I’ve replaced typescript-react-apollo with typescript-document-nodes and sometimes I can get…
-
How to allow Urql (typescript) to accept Vue reactive variables for queries created with graphql-codegen
2 I’m building a Vue project with urql and graphql-codegen. Urql has the ability to take Vue reactive variables when using useQuery() to enable useQuery to be reactive and update when the variables do. But graphql-codegen is creating the type for the variables parameter to require scalars (ex. string) and so typescript is throwing an…
-
Graphql codegen is always type unknown
1 I’m working in a SvelteKit project and want to use gql codegen, but all queries are typed as unknown. Ts file: import { graphql } from ‘$lib/gql/index.js’; export const getPostById = graphql(` query GET_ARTICLE($id: bigint!) { articles_by_pk(id: $id) { content created_at slug updated_at title } } `); codegen.ts import type { CodegenConfig } from…
-
Limit graphql-codegen by kind
0 I am using graphql-codegen to generate types for an internal package to allow graph queries to interact with a very small subset of the massive schema of a larger application. The stitched-schema has identically named objects of different kinds, which is resulting in invalid TypeScript as it generating identically named objects. The duplicate named…
-
GraphQL Code Generator with Apollo Client query with fragment type not detected
0 I have a simple Todo component that pulls all todos from my GraphQL endpoint. I am testing the fragment functionality using Apollo Client and GraphQL Code Generator to generate my types. Everything works, however the types for the fragment don’t (the data is there and displays correctly on the page). Below is the code…
-
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 };…
-
Facing incompatible module issue with inotify when try to install codegen
0 I tried to install codegen in react application using the below comment npm install –save-dev @graphql-codegen/cli @graphql-codegen/typescript @graphql-codegen/typescript-operations @graphql-codegen/typescript-react-apollo and i got the below error yarn add v1.22.19 [1/4] 🔍 Resolving packages… [2/4] 🚚 Fetching packages… error [email protected]: The platform "darwin" is incompatible with this module. error Found incompatible module. info Visit https://yarnpkg.com/en/docs/cli/add for…