Graphql-code-generator: VueJS?

Created on 22 Mar 2019  路  7Comments  路  Source: dotansimha/graphql-code-generator

It's becoming the next big thing and I am building my next project based on Vue/GraphQL/Graphene(Django).

Right now it seem a CRUD admin boilerplate based on GraphQL schema is a very good starting point for any project.

I know this probably isn't supported yet but I wonder if there are any thoughts among the developers on this framework.

Most helpful comment

Hi everybody. I've been working on a plugin that adds support for v4 of vue-apollo. https://github.com/vuejs/vue-apollo/releases/tag/v4.0.0-alpha.1
Check out this PR: https://github.com/dotansimha/graphql-code-generator/pull/3146

All 7 comments

Hi @gotexis ! We currently not maintaining a VueJS plugin (mostly because we miss the knowledge), we welcome the community to create one :)

I wrote project use google map api with first time use Vuejs framework , so i had some issues and try to find resolve 馃憤

Hi! 馃憢I've been wanting support for this because we define our constants with gql inside of our SFC script tags. I looked into how to parse a SFC file and it's very easy using vue-template-compiler:

const compiler = require('vue-template-compiler')
const parsed = compiler.parseComponent(fileData);
const script: string = parsed.script ? parsed.script.content : ''

// Hook into AST parser and gql tag finder here?

I looked at the source and it looks like all DocumentFile loading happens via @graphql-toolkit/<plugin> here:

https://github.com/dotansimha/graphql-code-generator/blob/877a6777b96bd68d85ec0b417aa2c3516cc408f9/packages/graphql-codegen-cli/src/load.ts#L16

It seems like we would need to add .vue file support to @graphql-toolkit/code-loader package here:

https://github.com/ardatan/graphql-toolkit/blob/6d1b3021d348144e8f447bdc0eceb0d6ef21b16c/packages/loaders/code-file/src/load-from-code-file.ts#L103

@dotansimha 1) Does this sound correct? and 2) if @graphql-toolkit doesn't want to support Vue files in their code-loader, can we write a custom VueFileLoader for graphql-code-generator that gets called by loadTypedefsUsingLoaders?

I tracked down the issue and it was easier than expected to fix, I made an upstream PR ardatan/graphql-toolkit#358.

Hi everybody. I've been working on a plugin that adds support for v4 of vue-apollo. https://github.com/vuejs/vue-apollo/releases/tag/v4.0.0-alpha.1
Check out this PR: https://github.com/dotansimha/graphql-code-generator/pull/3146

@bbugh The PR is merged and now we support vue files! Thank you @bbugh !!!

We can close this one :D

Was this page helpful?
0 / 5 - 0 ratings