Skip to content
This repository has been archived by the owner on Aug 20, 2020. It is now read-only.

[feature idea] graphql-tag support. #69

Open
gviligvili opened this issue Oct 2, 2017 · 5 comments
Open

[feature idea] graphql-tag support. #69

gviligvili opened this issue Oct 2, 2017 · 5 comments

Comments

@gviligvili
Copy link

I'm using apollo-fetch in my nodeJS server, to fetch data from my micro services which are also in graphql.

-- works fine. Thank you.

but the thing is that graphql-tag suppose to let us use fragments + let us use plugins which allow auto complete for fields and fragments. (which is EXTREMELY helpful in our huge schemas).

apollo client support it, so I though apollo-fetch would support it too, but I when I try to use apollo-fetch with graphql-tag - I get invalid json response from the microservice. (Java GraphQL).
without graphql - works great, but doesn't let me use very helpful features.

Thank you !

example :
works :

    const query = `
  query CurrentUser {
    currentUser {
      login,
    }
  }
`

doesn't work :

 import gql from 'graphql-tag';
 
 const query = gql`
  query CurrentUser {
    currentUser {
      login,
    }
  }
`

(Or is the java server responsibility? maybe I need to add him a tool to parse ast ?)

@codemonkey800
Copy link

It's unfortunate this issue has gone so long unanswered. I came across the same need to enable template syntax highlighting with the gql tag and vim.

If you take a look at the tests for apollo-fetch, you'll see the use of the gql tag and the function print().

So in your case, it would be:

import { createApolloFetch } from 'apollo-fetch';
import { print } from 'graphql';
import gql from 'graphql-tag';

const query = gql`
  query CurrentUser {
    currentUser {
      login,
    }
  }
`

const fetcher = createApolloFetch({ ... });
fetcher({ query: print(query) }).then(...).catch(...);

@cereallarceny
Copy link

Any knowledge on when this might be implemented? Kind of a buzzkill to have to use the gql string literal.

@laukaichung
Copy link

@codemonkey800
Thanks for the workaround.
I'm also waiting for the support of graphql-tag

@danieldunderfelt
Copy link

I'm curious about the reason why gql is not supported. It caught me completely by surprise, and the absence of gql before the template literal in the readme queries is NOT obvious, so I scratched my head for a few hours wondering why it wasn't working. A mention in the readme about stringifying graphql-tag queries or leaving gql out would be very welcome indeed.

@ctavan
Copy link
Contributor

ctavan commented Jun 1, 2018

As mentioned in #80 (and since #193 now also in the main README) this library is deprecated in favor of apollo-link.

Is migrating to apollo-link a viable solution for anyone in here?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants