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

Eliminate graphql dependency in production build #376

Open
madebyfabian opened this issue Sep 11, 2023 · 5 comments
Open

Eliminate graphql dependency in production build #376

madebyfabian opened this issue Sep 11, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@madebyfabian
Copy link

Your use case

Hi there! Thanks for this module.
I was inspecting my builds and I see that graphql gets bundled in there. I see that this module only uses the import { parse } from 'graphql' (https://github.com/search?q=repo%3ADiizzayy%2Fnuxt-graphql-client%20from%20%27graphql%27&type=code)

In my understanding, this method should only be needed while building. Or does this module read the .gql files in runtime from the server?

I see that it adds a good amount of KB's to my build:
Bildschirmfoto 2023-09-11 um 08 21 51

The solution you'd like

If it's possible, remove this dependency in production builds.

Possible alternatives

No response

Additional information

Similar issue: urql-graphql/urql#307

@madebyfabian madebyfabian added the enhancement New feature or request label Sep 11, 2023
@awdr74100
Copy link

@madebyfabian I would like to ask if this module is currently working properly?

@madebyfabian
Copy link
Author

@awdr74100 Hi, yes for me, everything works, except of Fragments. But I am not using the nuxt-graphql-server module like you described in #369.

@awdr74100
Copy link

@madebyfabian Thank you very much for your reply! I thought everyone could use the nuxt-graphql-server module except me...

@rylanharper
Copy link

rylanharper commented Sep 16, 2023

@madebyfabian fragments are working fine for me.. How are you setting them up?

The docs are very vague on this.. You have to create a fragments folder inside the queries folder. Then they would be set up like this:

fragment Image on Image {
  id
  altText
  height
  width
  url (transform: {
    maxHeight: 600,
    maxWidth: 400,
    crop: CENTER
  })
}

Then add them into your .gql queries with no import such as this:

image {
  ...Image
}

Hope this helps:)

@madebyfabian
Copy link
Author

@rylanharper Thanks for the details! This should absolutely be in the docs, since it's not standard graphql-ish behaviour. Now it's working.

Issue was: I named my fragment files MyFragment.fragment.gql to distinguish them easily from queries. Doing this does not work though.

If I find some time I'll create a docs PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants