Comments (5)
I'm on the same boat as you. I think there's no way to use with app router, at least from now. For the sake of seeking workarounds, your error happens to me when I try to call it in a page, like this:
import { MainTrivia } from '@/components/main-trivia'
import { useQuery, withWunderGraph } from '@/generated/nextjs'
import { NextPage } from 'next'
const Home: NextPage = () => {
const questions = useQuery({
operationName: 'survey/Questions',
input: {
id: '65610b6e03500e299a29d52d',
},
})
return (
<div className="container relative">
<section>
<MainTrivia questions={questions} />
</section>
</div>
)
}
export default withWunderGraph(Home)
node: v18
next: 14.0.3
The thing that works is to fetch directly to the wundergraph server (for example: http://127.0.0.1:9991/app/main/operations/AlbumById?albumId=${props.params.id}
) as in this blog post:
https://wundergraph.com/blog/data_fetching_with_next13
the thing is that I don't want to leave the wunderctl up
in prod.
Maybe someone has some solution or workaround for nextjs app layout based?
from wundergraph.
Digging further: I've tried to run client directly, as in this example project. However, if you look closer to the package.json
, the build
process looks like this:
"build": "wunderctl generate && next build",
But, the start
process:
"start": "npm run dev"
and not the standard next start
, making the wunderctl up
mandatory :(
Is there a way to get only the generated types but tell wundergraph like 'ok, if the env is PROD, call the original api.url
defined in the apis section of configureWunderGraphApplication
'?
from wundergraph.
By the way, here's also an example with the app dir.
https://github.com/wundergraph/wundergraph/tree/main/examples/nextjs-app-dir
from wundergraph.
I also ran into an issue like this, but for me it would only occur under certain conditions. Our issue is with "liveQuery" and ti failing in both client and server components. However, if you are not using live query then this may help.
We were able to get useQuery to work but only under these conditions:
- Not a live query
- useQuery is used in a "use client" component
- The parent component of the one using useQuery is also a a "use client" component
I've added a ticket for the liveQuery issue as well.
from wundergraph.
Any page or component where you use React state needs to be client component, same goes for useQuery, useMutation.
https://github.com/yessGlory17/wundergraph-next-router-migration/blob/master/app/page.tsx#L1
The page should have 'use client'
directive.
You can use the WunderGraph typescript client directly in server components.
const { data } = await client.query({
operationName: 'Dragons'
})
from wundergraph.
Related Issues (20)
- [Issue]: WG not sending query params when `statusCodeUnions` is `true` HOT 1
- 'SWRConfig' is not exported from '@wundergraph/swr' HOT 2
- [Issue]: mock server not working as expected HOT 2
- [Issue]: With openApiV2, BigInt cannot be serialized HOT 1
- [Issue]: Missing import sdk/server/fetch.ts HOT 4
- [Issue]: Scalar input fields on GraphQL datasource converted to strings HOT 13
- [Issue]: Live queries are not working when running server in debug mode (SvelteKit) HOT 2
- [Issue]: InputValidationError returns text/plain but should return application/json HOT 4
- [Issue]: Nextjs token based auth is not secure HOT 5
- Support for @tanstack/react-query v5 HOT 2
- Generated graphql Operations ignore the default values set in OAS Schema definition
- [Issue]: TestServer start timeout artificially limited to maximum of 60s HOT 1
- Object literal may only specify known properties, and 'type' does not exist in type 'JSONSchema7' HOT 5
- introspect.graphql does not work for Contetnful GQL Schema HOT 3
- [Issue]: NextJS 14 failing to run useQuery calls that are Live Queries HOT 5
- Remove dependency on terminate package HOT 1
- [Issue]: Unable to get headers in revalidate hook HOT 1
- [Issue]: Crash in Subscriptions after publishing an event to NATS. HOT 6
- [Issue]: wunderctl start from `@wundergraph/sdk:0.177.0` always returning `stack` property for operation errors HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wundergraph.