besteadfast / carbon

Steadfast's starter project - Craft CMS, Vite, and DDEV
3 stars 2 forks source link

Carbon & Nuxt #65

Open DrewTJohnson opened 1 week ago

DrewTJohnson commented 1 week ago

Issue for tracking Carbon / Nuxt connection.

The repo & branch pertaining to Nuxt can be found here: https://github.com/besteadfast/carbon-nuxt/tree/testlab/craft-nuxt

@btbunze @jakedohm Please add comments to this issue to show thoughts on pros/cons of this setup. I'll update this task with comments pertaining to my findings/general thoughts throughout the discovery process.

DrewTJohnson commented 1 week ago

Bringing in my slack comment for visibility


I was able to setup a graphql server/api in Nuxt to keep those queries on the server side: https://github.com/besteadfast/carbon-nuxt/blob/testlab/craft-nuxt/server/api/apollo.js This is the index page with the query on it: https://github.com/besteadfast/carbon-nuxt/blob/testlab/craft-nuxt/src/pages/index.vue I'm thinking we will be able to pass the page query into the server/api query. This would run our queries at build time instead of keeping them client side.

DrewTJohnson commented 1 week ago

@btbunze @jakedohm Using the way that we would query on the serverside, how do we feel about creating all of our queries under server/api?

My thinking here is that it would be redundant to have a queries/[whatever].js file for each query when we are already making the serverside calls to server/api/[whatever].js. So instead we would include the gql query in the server side api like in the example above.