Diizzayy / nuxt-graphql-client

⚡️ Minimal GraphQL Client + Code Generation for Nuxt3
https://nuxt-graphql-client.web.app
MIT License
366 stars 44 forks source link

Exposing the client in server routes #244

Closed chris-visser closed 2 years ago

chris-visser commented 2 years ago

Is there a way to expose the client in nitro / server routes? My proposal would be along the lines of:

export default defineEventHandler(async (event) => {
  const result = await event.context.gql()

  // maybe even nicer to expose a hook or a global function like $fetch

  const result = await $graphql('operation', variables)

})
Diizzayy commented 2 years ago

@chris-visser This feature is currently being worked on, and would follow the same implementation as per Gql Functions

hence usage would be as follows:

export default defineEventHandler(async (event) => {
  const result = await GqlGetTodos(variables)
})
chris-visser commented 2 years ago

Ahh nice! Really appreciate your work on this library and the timely response. Keep up the great work. Wish more gql clients would have a similar approach