Gomah / nuxt-graphql-request

Easy Minimal GraphQL client integration with Nuxt.js.
https://nuxt-graphql-request.vercel.app
MIT License
196 stars 16 forks source link

Import gql Module '"nuxt-graphql-request"' has no exported member 'gql'. #25

Closed jcjp closed 2 years ago

jcjp commented 3 years ago

Thank you for your library very easy to use however I am encountering an error when importing your library on TypeScript stated on the title: import gql Module '"nuxt-graphql-request"' has no exported member 'gql'.

Here is some of my code:

...
import {gql} from 'nuxt-graphql-request'

...

export default class MyPage extends Vue {
  async asyncData({$graphql}) {
   const query = ... // omitted
   const data = await $graphql.default.request(query)
   return {data}
  }
}

I was able to successfully query my data and display it on my website on JavaScript, however when switching to TypeScript I am encountering the said error.

mickaelchanrion commented 3 years ago

Hello, I have the same issue. I found a workaround thought, meanwhile this issue gets fixed:

import { gql } from 'graphql-tag'
jcjp commented 3 years ago

Hello, I have the same issue. I found a workaround thought, meanwhile this issue gets fixed:

import { gql } from 'graphql-tag'

I tried using that but encountered a different TypeScript error. We move to a different approach, and use this instead:

import {gql} from 'graphql-request'
rchl commented 3 years ago

This can be fixed easily in module's types but import {gql} from 'graphql-request' is technically the same so is fine to do instead.