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

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

Closed
vbutani opened this issue Sep 10, 2022 Discussed in #6873 · 8 comments
Labels
Stale Inactive issues

Comments

@vbutani
Copy link

vbutani commented Sep 10, 2022

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!]!
}

@vbutani vbutani changed the title GraphQL error GraphQL error Only executable definitions are supported in GraphQL Documents Sep 10, 2022
@vbutani vbutani changed the title GraphQL error Only executable definitions are supported in GraphQL Documents GraphQL Error: Only executable definitions are supported in GraphQL Documents Sep 10, 2022
@vbutani vbutani changed the title GraphQL Error: Only executable definitions are supported in GraphQL Documents @parcel/transformer-graphql: Only executable definitions are supported in GraphQL Documents. Sep 10, 2022
@KillerCodeMonkey
Copy link
Contributor

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
Copy link
Author

vbutani commented Sep 16, 2022

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

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

@KillerCodeMonkey
Copy link
Contributor

KillerCodeMonkey commented Sep 16, 2022 via email

@vbutani
Copy link
Author

vbutani commented Sep 16, 2022

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
Copy link
Contributor

KillerCodeMonkey commented Sep 16, 2022 via email

@vbutani
Copy link
Author

vbutani commented Sep 21, 2022

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
Copy link

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
Copy link

github-actions bot commented Jul 2, 2023

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.

@github-actions github-actions bot added the Stale Inactive issues label Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Inactive issues
Projects
None yet
Development

No branches or pull requests

3 participants