B. *_*nie 11 graphql prisma-graphql
我的目标:我想在 GraphQL Playground 中执行一个变更。
我的架构如下所示:
type Mutation {
# Add a new comment
addComment(comment: InputComment!): Comment
}
# Input type for a new Comment
input InputComment {
# The comment text
comment: String!
# The id of the author
author: String!
# The id of the talk
talkId: Long!
}
Run Code Online (Sandbox Code Playgroud)
我发现了很多例子,如果我有:
type Mutation {
# Add a new comment
addComment(comment: String!, author: String!, talkId: Long!): Comment
}
Run Code Online (Sandbox Code Playgroud)
但我无法理解如何InputComment
在 GraphQL Playground 中动态创建类型对象。
例如,对于最后一个场景,我可以运行:
mutation {
addComment(
comment: "My great comment"
author: "The great author"
talkId: 123
) {
id
}
}
Run Code Online (Sandbox Code Playgroud)
B. *_*nie 17
mutation {
addComment(comment: {comment: "Cool", author: "Me", talkId: 12}) {
createdOn
id
}
}
Run Code Online (Sandbox Code Playgroud)
小智 8
type Comment {
id: ID!
comment: String!
author: String!
talkId: Long!
}
# Input type for a new Comment
input InputComment {
comment: String!
author: String!
talkId: Long!
}
type Mutation {
# Add a new comment
addComment(comment: InputComment!): Comment
}
##Then query should be
mutation {
addComment(comment: {comment: "test comment", author: "Sample name", talkId: 123}) {
id,
comment,
author,
talkId
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13126 次 |
最近记录: |