-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Unknown fragment in server functions #333
Comments
Did anyone manage to get fragments working? |
@nonlinearcom Not working for me either. Same error. |
same problem here, is there any solution ? |
Also looking for more info on this |
Fragments are working just fine in my project (I am using the Shopify API, so a lot of fragments lol).. I posted this response on another thread, but I will add it here too: The docs are very vague on this.. You have to create a
Then add them into your
Hope this helps:) |
@rylanharper I updated @iBobik's reproduction accordingly: https://stackblitz.com/~/github.com/vernaillen/nuxt-graphql-client-serverfragments |
@vernaillen Hmm you know what.. you are correct. Sorry, my mistake, my server routes in my project are actually using plain queries without the fragments being used. I thought I had had two fragments within my query, but I typed them out instead so I guess I ran into this issue as well when I was working on that aspect of the project. Ignore my post above, it does work client-side, but my fragments not working on the server routes upon adding them in. |
I have a same issue. Fragments works fine on Client-side, but on server side I have same error as is in first post. Maybe, I am using it wrong, but if I compare Gql in Client-side, it works fine, but on server api routes return error for unknown Fragment. If I inspect nitro-imports, there is a Gql function, but with different import, from |
Indeed, fragments do not work when called in event handlers in the server directory. |
@vernaillen - the example you posted above seems to be a broken link now Is there anywhere else i can see an example of how it is supposed to work in the first place? I'm just now wanting to use fragments, and have been storing my graphql queries like so:
I've had no problems with this approach. But it sounds like Will my directory structure cause problems? Is there a definitive example I haven't been able to find. I've looked in the docs, issues, discussions and the broken link so far. I've had no luck getting my fragment to be incorporated. |
I was able to see how fragments should work by running the playground. |
Same issue here. Anyone able to assist me into resolving this issue? |
Seems like codegen is not used for the operations that are injected into nitro. Setting I'm not familiar enough with the nitro quirks to add codegen support for the nitro operations... Would be great if someone with more nitro experience could provide some pointers. For now, I am using this as an ugly workaround:
|
🙏 for the pull request to be merged. |
Any news on this ? |
Any updates? this has been open for over a year now.... |
Can you tell us more about how to implement this so it works for us? I have no clue where you put this piece of code. Thanks! |
Environment
Describe the bug
Fragments are lost on the way when called in the server routes. Definition:
When called GqlGetOrderItem it fails with this error:
It is visible in a response that fragment was not included at the end.
In .nuxt/gql/default.ts it seems correct:
Same fragments works when used client-side in the SPA.
Expected behaviour
Fragment will be included in this request.
Reproduction
https://stackblitz.com/edit/github-twqhau?file=server%2Fapi%2Ftest.ts
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: