0

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

输入:

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

输出:

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

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

let output = getTagFromString(input);

useQuery(output);
4

1 回答 1

1

你可以写

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

useQuery(output);
于 2020-03-25T21:45:56.330 回答