Fitch
11/15/2017, 6:17 PMtimwis
11/15/2017, 7:55 PMuser: User!
property, allowing the client to specify which fields, and even get a related object. Is that possible? All the examples return explicit fields only in a custom object.Kat
11/15/2017, 9:51 PMKat
11/15/2017, 9:51 PMbobbyt
11/15/2017, 10:02 PMCombined
You can also use tags and tagsIds in the same mutation, this would connect the new Tutorial node to all the tags in tagsIds and connect it to the new tags in tags. This is what you want to do if you want to only allow tags with a unique text, so for a new Tutorial, there will likely be some tags that already exists, and some that need to be created.In my case, I am trying to update a set of tags on a Post. I am able to pass both
tags
(new tags) and tagsIds
(ids of tags that already exist) to my mutation:
const updatePostQuery = ({
id,
createdById,
timestamp,
imageUrl,
description,
tags,
tagsIds,
}) => ({
mutation: gql`
mutation updatePost(
$id: ID!
$createdById: ID!
$timestamp: DateTime!
$imageUrl: String
$description: String
$tags: [PosttagsTag!]!
$tagsIds: [ID!]
) {
updatePost(
id: $id
createdById: $createdById
timestamp: $timestamp
imageUrl: $imageUrl
description: $description
tags: $tags
tagsIds: $tagsIds
) {
id
timestamp
description
tags {
id
tag
}
imageUrl
createdBy {
id
username
}
}
}
`,
variables: {
id,
createdById,
timestamp,
imageUrl,
description,
tags,
tagsIds,
},
});
However, I get the following error:
ERROR: [Error: GraphQL error: A unique constraint would be violated on Post. Details: Sorry, no more details available.]
While the new tag is added successfully the mutation seems to be trying to append the ids of the existing tags to the field instead of updating their values?sebastien
11/15/2017, 10:04 PMMiezan
11/15/2017, 11:45 PMamanda_hogan
11/16/2017, 1:35 AMquery {
allAnswers(filter: {
keywords_contains: "location"
}) {
response
}
}
This is an example of the Type in the schema type Answer @model {
id: ID! @isUnique
intent: String!
keywords: [String!]
response: String!
subject: String! @isUnique
timeStamp: DateTime!
}
and I am getting this error {
"data": null,
"errors": [
{
"message": "Argument 'filter' expected type 'AnswerFilter' but got: {keywords_contains: \"location\"}. Reason: 'keywords_contains' Field 'keywords_contains' is not defined in the input type 'AnswerFilter'. (line 2, column 22):\n allAnswers(filter: {\n ^\n (line 3, column 5):\n keywords_contains: \"location\"\n ^",
"locations": [
{
"line": 2,
"column": 22
},
{
"line": 3,
"column": 5
}
]
}
]
}
can someone point out where I am going wrong.virtualirfan
11/16/2017, 2:03 AMType
in the Console would automatically create and maintain the createdAt
and updatedAt
fields. Am I misremembering? Now, it looks like they are there for the system types but not the user types. What gives?gauravkaushik
11/16/2017, 2:16 AMMoonTahoe
11/16/2017, 3:38 AMFitch
11/16/2017, 4:13 AMdivyendu
11/16/2017, 7:12 AMMaslov
11/16/2017, 7:45 AMVinnie
11/16/2017, 9:23 AMNo service with id 'cj9ttwnlb009h0150kg59sgb0' in account <mailto:test@test.org|test@test.org>. Please check if you are logged in to the right
▸ account.
What’s right way to approach this? It is only removing the local target from .graphcoolrc
?rein
11/16/2017, 9:38 AMtfiwm
11/16/2017, 10:02 AMtfiwm
11/16/2017, 10:02 AMdtuite
11/16/2017, 11:38 AMpokorson
11/16/2017, 1:24 PMpokorson
11/16/2017, 1:25 PMGlobal
✖ Could not create serverless function for 'authenticate'. Ensure that the code is valid
proteus
11/16/2017, 1:49 PMproteus
11/16/2017, 1:49 PMproteus
11/16/2017, 1:50 PMbobbyt
11/16/2017, 1:52 PMupsert
when issuing a mutation on a nested one-to-many field. In my case, I have a Post
type than has a tag
field which can be associated with many `Tag`s. The issue I am running into is when updating a Post
- I need to both create new `Tag`s for tags that do not yet exist, and for ones that do only provide an association to existing Tag
ids. Here is my schema:
type Post @model {
createdAt: DateTime!
createdBy: User @relation(name: "PostsByUser")
description: String @defaultValue(value: "''")
id: ID! @isUnique
tags: [Tag!]! @relation(name: "TagsOfPost")
...
}
type Tag @model {
id: ID! @isUnique
tag: String!
createdBy: User @relation(name: "TagsByUser")
createdAt: DateTime!
posts: [Post!]! @relation(name: "TagsOfPost")
}
I came across this post by @nilan but it's not clear how to implement the combined method he outlines:
https://www.graph.cool/forum/t/how-do-i-add-an-array-of-objects-to-a-mutation-in-apollo-react/365/6
Combined
You can also use tags and tagsIds in the same mutation, this would connect the new Tutorial node to all the tags in tagsIds and connect it to the new tags in tags. This is what you want to do if you want to only allow tags with a unique text, so for a new Tutorial, there will likely be some tags that already exists, and some that need to be created.Is it currently impossible to do this with one mutation? Would a second mutation be required to add the associations to existing
Tag
ids? Thanks!mwickett
11/16/2017, 2:06 PMmwickett
11/16/2017, 2:07 PMJohn Livingston
11/16/2017, 2:43 PMJohn Livingston
11/16/2017, 2:43 PMnilan
11/16/2017, 2:48 PM