babel-plugin-import-graphql icon indicating copy to clipboard operation
babel-plugin-import-graphql copied to clipboard

Provide d.ts as part of lib

Open JustFly1984 opened this issue 5 years ago • 2 comments

There is no @types/babel-plugin-import-graphql

I've tried to generate .d.ts with dts-gen, but it produces empty file.

JustFly1984 avatar Mar 02 '19 17:03 JustFly1984

I use this with a typescript project I'm working on and haven't needed types for it since it's only used indirectly at compile time. Are you getting any kind of warnings?

detrohutt avatar Mar 03 '19 19:03 detrohutt

Yes, I do get warnings. I'm using it as

// @ts-ignore
import { requireGql } from 'babel-plugin-import-graphql/build/requireGql'

we are using aws-amplify, but now limiting it to only auth, and disabled their outdated graphql

and in gatsby 
```jsx
const createPages = async ({ actions: { createPage } }: CreatePagesArgs) => {
  const { getHome } = requireGql(path.resolve('./src/graphql/user.gql'))

  const query = print(getHome)

  const url = `${getEndpoint('user')}/graphql-incognito`

  console.log('url: ', url)

  return fetch(url, {
    method: 'post',
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      query
    })
  }).then((response: any) =>
    response.json()
  ).then((result: any) => {
    console.error(result)
    if (
      result.data === undefined ||
      result.errors !== undefined
    ) {
      throw result.errors
    }

This is the only place in whole project I use @ts-ignore

JustFly1984 avatar Mar 03 '19 21:03 JustFly1984