Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
996 views
in Technique[技术] by (71.8m points)

graphql - 查询可以用于数据写入吗?(Can Queries be used for data writing?)

For my GraphQL app I'd like to save logs of certain resolved fields.

(对于我的GraphQL应用程序,我想保存某些已解析字段的日志。)

Because the users can view these logs themselves, should that be considered apart of a mutation instead of a query?

(由于用户可以自己查看这些日志,因此应该将其视为突变而不是查询的一部分吗?)

Since it's not the application's focus I'd assume that using a mutation is overkill, but I'm not sure if there's some sort of side effects I'm going to run into by modeling it in such a way.

(由于不是应用程序的重点,因此我认为使用突变是过大的,但是我不确定通过这种方式进行建模是否会产生某种副作用。)

The other questions I've read didn't really answer this question, so sorry if this seems like a duplicate.

(我读过的其他问题并没有真正回答这个问题,如果这看起来像是重复的,那么抱歉。)

  ask by Shawn LaFrance translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The mutation keyword is just a bit of syntax to say "hey this is gonna edit or create something" otherwise Query and Mutation do the same thing.

(关键字mutation只是表达“嘿,这将要编辑或创建某些内容”的语法,否则“查询”和“更改”将执行相同的操作。)

I think here, in your case, its a better decision to perform a Query & store the event in your Audit log.

(我认为,就您而言,执行查询并将事件存储在审核日志中是一个更好的决定。)

Exposing the fact that the Query stores an audit log is an implementation-specific detail & clients shouldn't know about it.

(暴露查询存储审计日志这一事实是特定于实现的详细信息,客户不应该知道。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...