如何从字符串中获取qql表达式

How to get qql expression from String

我有一个带有 GraphQL 查询的字符串变量。我想编写将 return 这个 gql 标记的函数。能不能帮我写一下。例如:

输入:

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

输出:

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

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

let output = getTagFromString(input);

useQuery(output);

你可以写

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

useQuery(output);