[英]GraphQL query structure
I'm learning GraphQL and am working with Apollo (client and server) I still have some confusion with the structure of GraphQL queries.我正在学习 GraphQL 并且正在使用 Apollo(客户端和服务器)我仍然对 GraphQL 查询的结构有些困惑。
Questions:问题:
#1
and #2
together?是否可以将标记为#1
和#2
的行合并在一起? As the lines are so similar it almost feels redundant to have both.由于线条非常相似,因此两者兼有几乎是多余的。const AddUserQuery = gql`
/*#1*/mutation addUser($firstName: String!, $lastName: String!, $email: String!) {
/*#2*/addUser(firstName: $firstName, lastName: $lastName, email: $email) {
id,
firstName,
lastName,
email
}
}`;
...
const [addUser, {data}] = useMutation(AddUserQuery);
Thanks in advance,提前致谢,
No. Basically #1
is you, telling Apollo you want a mutation, it's up to you if you name it or not, then, in #2
, you're telling Apollo, which mutation you want to use.不。基本上#1
是你,告诉 Apollo 你想要一个突变,你是否命名它取决于你,然后,在#2
中,你告诉 Apollo,你想使用哪个突变。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.