Using graphql request inside `generate` to request data for routes?
See original GitHub issueThis is more of a question than an issue. We’re currently using nuxt-graphql-request
in our project and it’s working great.
However, we’re looking to make a graphQL request in the generate
property of the Nuxt config in order to generate routes based on the query response, something similar is outlined in this post which uses Apollo:
https://rosso.codes/blog/nuxt-generate-dynamic-routes-with-apollo-and-graphql/
Wondering if there’s a way to reference/access the graphql
property created in the Nuxt config INSIDE another property in the config? Obviously we can’t use this.$graphql
inside the generate
property.
Or perhaps there’s a way to do this using middleware? Any thoughts welcome. Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Serving over HTTP - GraphQL
Your GraphQL HTTP server should handle the HTTP GET and POST methods. GET request#. When receiving an HTTP GET request, the GraphQL query...
Read more >How To Build A GraphQL Server Using Next.js API Routes
In this guide, we will be first learning what are API Routes, and then create a GraphQL server that retrieves the data from...
Read more >Custom Routes for External Data with GraphQL - Strapi
The first thing is to create a reusable Query component that we can use anywhere in our code to fetch the \graphql endpoint....
Read more >How to Fetch GraphQL Data in Next.js with Apollo GraphQL
When fetching data, instead of making a GET request to a URL to grab that data, GraphQL endpoints take a “query”. That query...
Read more >4 Simple Ways to Call a GraphQL API
Passing the GraphQL query to the useQuery hook gives us an object that can be de-structured into loading , error , and data...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @alexmahan, indeed, you can’t use
this.$graphql
inside the generate property as, you have to usegraphql-request
like the following example:Thanks for the reply! I have the queries working inside Vue files, but I’d need to include it in
nuxt.config.js
so I could use it in thegenerate.routes
option