Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL Codegen Plugin Setup #60

Closed
kingkong404 opened this issue Oct 18, 2020 · 1 comment
Closed

GraphQL Codegen Plugin Setup #60

kingkong404 opened this issue Oct 18, 2020 · 1 comment
Labels
❔ question Further information is requested

Comments

@kingkong404
Copy link

What codegen plugins would be best to combine with Villus?

For example is it compatible with the output of @graphql-codegen/typescript-vue-apollo

@logaretm
Copy link
Owner

Unfortunately, I don't think it is compatible with @graphql-codegen/typescript-vue-apollo output

However, we do use the near-operation-preset along with typescript-operation plugin to generate .gql defenitions.

Here is a snippet of the codegen.yml:

schema: https://yourapi.com/graphql
documents:
  - ./graphql/**/*.gql
generates:
  ./graphql-types.gen.ts:
    plugins:
      - typescript
  ./:
    preset: near-operation-file
    presetConfig:
      extension: .gql.d.ts
      baseTypesPath: graphql-types.gen.ts
    plugins:
      - typescript-operations
config:
  addOperationExport: true

Which provides typings for our schema and for the operations we use with graphql-tag.

Here is an example of a query:

import { ProductsQuery, ProductsQueryVariables, Products } from '@/graphql/Product.gql';

const { data, error } = useQuery<ProductsQuery, ProductsQueryVariables>({
  query: Products,
  variables,
});

Maybe in the future, I could implement a plugin to automate this like the one you suggested for vue-apollo but I'm short on time at the moment.

@logaretm logaretm added the ❔ question Further information is requested label Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❔ question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants