Open
Description
Environment
- Operating System: Darwin
- Node Version: v18.16.0
- Nuxt Version: 3.4.3
- Nitro Version: 2.4.0
- Package Manager: [email protected]
- Builder: vite
- User Config: ssr, css, build, devServer, modules, runtimeConfig
- Runtime Modules: [email protected]
- Build Modules: -
Describe the bug
Fragments are lost on the way when called in the server routes. Definition:
fragment OrderItem on OrderItem {
orderCode
creationTime
status
}
query getOrderItem ($orderCode: String!, $offerID: UUID!) {
orderItem: getOrderItem (by: { orderCode: $orderCode, offer: { id: $offerID } }) {
...OrderItem
}
}
When called GqlGetOrderItem it fails with this error:
[nuxt] [request error] [unhandled] [500] Unknown fragment "OrderItem".: {"response":{"errors":[{"message":"Unknown fragment \"OrderItem\".","locations":[{"line":3,"column":8}]}],"status":400,"headers":{}},"request":{"query":"query getOrderItem ($orderCode: String!, $offerID: UUID!) {\n orderItem: getOrderItem (by: { orderCode: $orderCode, offer: { id: $offerID } }) {\n ...OrderItem\n }\n}","variables":{"orderCode":"2023000001","offerID":"db27911f-0bc9-49cb-b27b-ca7f8a5f8a7f"}}}
at ./node_modules/graphql-request/dist/index.js:395:31
at step (./node_modules/graphql-request/dist/index.js:63:23)
at Object.next (./node_modules/graphql-request/dist/index.js:44:53)
at fulfilled (./node_modules/graphql-request/dist/index.js:35:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
It is visible in a response that fragment was not included at the end.
In .nuxt/gql/default.ts it seems correct:
export const OrderItemFragmentDoc = gql`
fragment OrderItem on OrderItem {
orderCode
creationTime
status
}
`;
…
export const GetOrderItemDocument = gql`
query getOrderItem($orderCode: String!, $offerID: UUID!) {
orderItem: getOrderItem(by: {orderCode: $orderCode, offer: {id: $offerID}}) {
...OrderItem
}
}
${OrderItemFragmentDoc}`;
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