dulnan / nuxt-graphql-middleware

GraphQL in the backend, fetch in the frontend. With TypeScript support.
https://nuxt-graphql-middleware.dulnan.net
MIT License
56 stars 11 forks source link

Support for nuxt layers #29

Closed asonnleitner closed 4 weeks ago

asonnleitner commented 6 months ago

It would be cool if graphql files would support nuxt layers

dulnan commented 4 months ago

Is there something in particular that didn't work for you? I have successfully used this module with layers before, even having different query files per layer.

asonnleitner commented 4 months ago

@dulnan I believe I had some issues with the GraphQL files when using fragment imports. I had them stored at both the root level and the project level, but the imports did not resolve correctly.

dulnan commented 4 months ago

Ah I see. I will setup a playground that uses layers to try to debug this. What should work is to always reference the fragment imports by their full path.

I'm also currently working on a feature to automatically inline fragments without the need to specify an import. That should also fix the issue with layers, as long as there are no two fragments with the same name in multiple layers or layer and root.

asonnleitner commented 4 months ago

@dulnan That sounds awesome! 🔥

asonnleitner commented 4 months ago

@dulnan Here is something I worked in the past https://github.com/dulnan/nuxt-graphql-middleware/pull/33, which removes @graphql-fragment-import/lib and use a typescript module I wrote, it is also more performant and uses new newer JS API, like function generators, Maps and Sets. Feel free to make any changes.

dulnan commented 4 months ago

Both your refactored fragment import and the new "auto inline fragments" feature have been released in 4.1.0: https://nuxt-graphql-middleware.dulnan.net/features/fragments.html#automatic-import

I still need to add a "layers playground", so I'll keep this issue open for the time being.