0

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);
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Vadim
  • 557
  • 8
  • 21

1 Answers1

1

You can write

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

useQuery(output);
Bergi
  • 630,263
  • 148
  • 957
  • 1,375