Coder Social home page Coder Social logo

GraphQL Codegen Plugin Setup about villus HOT 1 CLOSED

logaretm avatar logaretm commented on May 23, 2024
GraphQL Codegen Plugin Setup

from villus.

Comments (1)

logaretm avatar logaretm commented on May 23, 2024 1

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.

from villus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.