How to get qql expression from String

53 views Asked by At

I have a String variable with GraphQL query. I want to write function which will return this the gql tag. Could you help me to write it. For example:

Input:

let input = `query { employee { id surname } }`;

Output:

let output = gql`query { employee { id surname } }`;

const getTagFromString = (input) => {  ?????   };

let output = getTagFromString(input);

useQuery(output);
1

There are 1 answers

0
Bergi On BEST ANSWER

You can write

let input = "query { employee { id surname } }";
let output = gql([input]);

useQuery(output);