parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.45k stars 2.27k forks source link

@parcel/transformer-graphql: Only executable definitions are supported in GraphQL Documents. #8461

Closed vbutani closed 1 year ago

vbutani commented 2 years ago

I am trying to migrate my frontend react project from webpack to Parcel 2, but stuck with following GraphQL error and not getting help around it, please advise.

@parcel/transformer-graphql: Only executable definitions are supported in GraphQL Documents.

package versions: "graphql": "^15.8.0", "graphql-tag": "^2.12.6", "@parcel/transformer-graphql": "^2.7.0", "@parcel/transformer-sass": "^2.7.0", "parcel": "latest"

The .graphql file which gives an error is as follows:-

add-product.graphql

mutation AddProduct($id: String!, $comnId: [String!]!, $products: [AuthorizeProduct!]!, $pSalesLevel: String){ authorizeProduct(id: $routeEnvId, comnId: $comnId, products: $products, pSalesLevel: $pSalesLevel) { authorizeProductStatuses { error routeEnvId arloComb productId fiscalWeekIds } } }

input AuthorizeProduct { productId: Int! fiscalWeekIds: [Int!]! }

KillerCodeMonkey commented 2 years ago

i would guess: parcel graphql transformer can only parse operations (mutations, queries, subscriptions) and not input type or fragment definitions, yet.

In your case i would use something more stable for graphql files, like https://www.graphql-cli.com/codegen/ for now. define your graphql files -> execute the code generation and just import the generated hooks, types and so on.

vbutani commented 2 years ago

i would guess: parcel graphql transformer can only parse operations (mutations, queries, subscriptions) and not input type or fragment definitions, yet.

In your case i would use something more stable for graphql files, like https://www.graphql-cli.com/codegen/ for now. define your graphql files -> execute the code generation and just import the generated hooks, types and so on.

Thanks for the suggestion, I tried graphql-cli, but it gives another error and that library is not being actively maintained. https://github.com/Urigo/graphql-cli/issues/1807

To cross check if it's my code issue, I tried Vite.js 3 bundler and my .graphql file works fine with it.

KillerCodeMonkey commented 2 years ago

Sorry I sent you the wrong link

I ment https://github.com/dotansimha/graphql-code-generator

vbutani @.***> schrieb am Fr., 16. Sept. 2022, 15:44:

i would guess: parcel graphql transformer can only parse operations (mutations, queries, subscriptions) and not input type or fragment definitions, yet.

In your case i would use something more stable for graphql files, like https://www.graphql-cli.com/codegen/ for now. define your graphql files -> execute the code generation and just import the generated hooks, types and so on.

Thanks for the suggestion, I tried graphql-cli, but it gives another error and that library is not being actively maintained. Urigo/graphql-cli#1807 https://github.com/Urigo/graphql-cli/issues/1807

To cross check if it's my code issue, I tried Vite.js 3 bundler and my .graphql file works fine with it.

— Reply to this email directly, view it on GitHub https://github.com/parcel-bundler/parcel/issues/8461#issuecomment-1249384300, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARI4YDZYEOSVRN3BOR2ONTV6R2U7ANCNFSM6AAAAAAQJOQSWY . You are receiving this because you commented.Message ID: @.***>

vbutani commented 2 years ago

Sorry I sent you the wrong link I ment https://github.com/dotansimha/graphql-code-generator vbutani @.> schrieb am Fr., 16. Sept. 2022, 15:44: … i would guess: parcel graphql transformer can only parse operations (mutations, queries, subscriptions) and not input type or fragment definitions, yet. In your case i would use something more stable for graphql files, like https://www.graphql-cli.com/codegen/ for now. define your graphql files -> execute the code generation and just import the generated hooks, types and so on. Thanks for the suggestion, I tried graphql-cli, but it gives another error and that library is not being actively maintained. Urigo/graphql-cli#1807 <Urigo/graphql-cli#1807> To cross check if it's my code issue, I tried Vite.js 3 bundler and my .graphql file works fine with it. — Reply to this email directly, view it on GitHub <#8461 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARI4YDZYEOSVRN3BOR2ONTV6R2U7ANCNFSM6AAAAAAQJOQSWY . You are receiving this because you commented.Message ID: @.>

This code generator works, but I am not using Typescript in my project and sorry for lack of my knowledge as I am not getting how this code generator will help me resolve the parcel graphql transformer error? It generates the .tsx file which is not useful to me.

KillerCodeMonkey commented 2 years ago

The idea was that you can write graphql files, but you do not have to import them.

So no need to use graphql transformer ;-).

But I do not know your exact setup. So it was just an idea.

In some of my typescript projects i use it to generate my schemes and types

So you have js/ts files you can import, which parceljs is able to bundle and optimize.

vbutani @.***> schrieb am Fr., 16. Sept. 2022, 22:46:

Sorry I sent you the wrong link I ment https://github.com/dotansimha/graphql-code-generator vbutani @.

> schrieb am Fr., 16. Sept. 2022, 15:44: … <#m2491856110758750672> i would guess: parcel graphql transformer can only parse operations (mutations, queries, subscriptions) and not input type or fragment definitions, yet. In your case i would use something more stable for graphql files, like https://www.graphql-cli.com/codegen/ https://www.graphql-cli.com/codegen/ for now. define your graphql files -> execute the code generation and just import the generated hooks, types and so on. Thanks for the suggestion, I tried graphql-cli, but it gives another error and that library is not being actively maintained. Urigo/graphql-cli#1807 https://github.com/Urigo/graphql-cli/issues/1807 <Urigo/graphql-cli#1807 https://github.com/Urigo/graphql-cli/issues/1807> To cross check if it's my code issue, I tried Vite.js 3 bundler and my .graphql file works fine with it. — Reply to this email directly, view it on GitHub <#8461 (comment) https://github.com/parcel-bundler/parcel/issues/8461#issuecomment-1249384300>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARI4YDZYEOSVRN3BOR2ONTV6R2U7ANCNFSM6AAAAAAQJOQSWY https://github.com/notifications/unsubscribe-auth/AARI4YDZYEOSVRN3BOR2ONTV6R2U7ANCNFSM6AAAAAAQJOQSWY . You are receiving this because you commented.Message ID: @.>

This code generator works, but I am not using Typescript in my project and sorry for lack of my knowledge as I am not getting how this code generator will help me resolve the parcel graphql transformer error?

— Reply to this email directly, view it on GitHub https://github.com/parcel-bundler/parcel/issues/8461#issuecomment-1249796349, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARI4YBF2NWCQ72YL2LQINDV6TMCJANCNFSM6AAAAAAQJOQSWY . You are receiving this because you commented.Message ID: @.***>

vbutani commented 2 years ago

I am still facing the same issue. Please advise. I do not use TypeScript in my project and schema.graphql is in separate backend project. UI project has gql queries and mutations using Apollo client v2 library.

magnusart commented 1 year ago

Ended up here because I got the same error. I'll continue looking, however I noticed that there seem to be an error in your graphql query: id: $routeEnvId is not defined anywhere in AddProduct.

mutation AddProduct($id: String!, $comnId: [String!]!, $products: [AuthorizeProduct!]!, $pSalesLevel: String){
authorizeProduct(id: $routeEnvId, comnId: $comnId, products: $products, pSalesLevel: $pSalesLevel) {

I'm wondering if the parcel plugin just emits an unhelpful error.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.