S
S
Sashqa2020-01-27 17:30:06
Node.js
Sashqa, 2020-01-27 17:30:06

How to import properly graphql query on node js?

We have a fairly large project in Angular. Apollo is used to work with graphql.
I needed to write a service on node js and I need to import requests for graphql
But the problem is that all these requests are wrapped in gql``

I don’t want to import Apollo into this service either, tell me how can I get the request itself?

Request example

export const ContractQuery = gql`
query getContract($id: Long!){}`

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
twolegs, 2020-01-27
@Sashqa

For gql, you do not need to drag the entire Apollo, just include the graphql-tag package.
To bring it all to a line, you can do this:

import { print } from 'graphql/language/printer'

console.log(print(query))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question