mutation addUser($user: AddUserInput!) {
addUser(input: [$user]) {
user {
...UserSummary
}
}
}
I have a problem using input types as mutation parameters. The query and parameters are parsed and accepted by engine but query returns null.
input AddUserInput {
about: String
avatarUrl: String
followers: [UserRef!]
following: [UserRef!]
guides: [GuideRef!]
images: [ImageRef!]
interests: [ActivityRef!]
isVerified: Boolean
languages: [LanguageRef!]
ownedByYou: [EventRef!]
registrationDate: DateTime
userAlias: String!
username: String!
yourPlaces: [PlaceRef!]
}
Parameters
{
"user": {
"username": "fijvhufch@gmail.com",
"userAlias": "j7ffyffyg",
"languages": [
{
"name": "English"
}
],
"interests": [
{
"name": "Sky Diving"
}
]
}
}
I also have problem with this query:
mutation addUser(
$username: String!,
$userAlias: String!,
$languages: [LanguageRef!],
$interests: [ActivityRef!]
) {
addUser(input: [{
username: $username,
userAlias: $userAlias,
languages: $languages,
interests: $interests
}], upsert: true) {
user {
username,
userAlias,
}
}
}
input ActivityRef {
name: String!
}
input LanguageRef {
name: String!
}
And this is outcome
{
"data": {
"addUser": null
},
"extensions": {
"touched_uids": 15,
"tracing": {
"version": 1,
"startTime": "2022-07-20T16:27:53.822405129Z",
"endTime": "2022-07-20T16:27:53.986954664Z",
"duration": 164549545,
"execution": {
"resolvers": [
{
"path": [
"addUser"
],
"parentType": "Mutation",
"fieldName": "addUser",
"returnType": "AddUserPayload",
"startOffset": 147104,
"duration": 164395561,
"dgraph": [
{
"label": "preMutationQuery",
"startOffset": 196472,
"duration": 10256710
},
{
"label": "mutation",
"startOffset": 10522115,
"duration": 102941868
},
{
"label": "query",
"startOffset": 0,
"duration": 0
}
]
}
]
}
}
}
}
Update does not work either.
mutation MyMutation($userAlias: String!, $username: String!, $languages: [LanguageRef!] = {name: ""}, $interests: [ActivityRef!] = {name: ""}, $about: String = "") {
updateUser(input: {filter: {username: {eq: $username}}, set: {about: $about, userAlias: $userAlias, languages: $languages, interests: $interests}}) {
user {
userAlias
username
languages {
name
}
interests {
name
}
}
}
}
{
"username": "filip.matuszewskddsi2@gmail.com",
"userAlias": "phellippe5dd",
"languages": [
{
"name": "English"
}
],
"interests": [
{
"name": "Sky Diving"
}
]
}
Response
{
"data": {
"updateUser": null
},
"extensions": {
"touched_uids": 21,
"tracing": {
"version": 1,
"startTime": "2022-07-20T20:24:00.077725369Z",
"endTime": "2022-07-20T20:24:00.207973319Z",
"duration": 130247950,
"execution": {
"resolvers": [
{
"path": [
"updateUser"
],
"parentType": "Mutation",
"fieldName": "updateUser",
"returnType": "UpdateUserPayload",
"startOffset": 231623,
"duration": 130008687,
"dgraph": [
{
"label": "preMutationQuery",
"startOffset": 285074,
"duration": 3778703
},
{
"label": "mutation",
"startOffset": 4177999,
"duration": 123818969
},
{
"label": "query",
"startOffset": 0,
"duration": 0
}
]
}
]
}
}
}
}
Can you supply the schema for your User
type as well as the Language and Interest types?
matthewmcneely:
User
type User {
about: String
username: String! @id
userAlias: String!
avatarUrl: String
interests: [Activity!]
languages: [Language!]
following: [User!] @hasInverse(field:followers)
followers: [User!] @hasInverse(field:following)
registrationDate: DateTime
isVerified: Boolean
}
type Language {
name: String! @id
}
type Activity
{
name: String! @id
}
{
"errors": [
{
"message": "mutation addUser failed because Dgraph execution failed because : context deadline exceeded",
So the “context deadline exceeded” may be related to this issue . Guessing this is against a cloud instance?
1 Like
I think I had a problem with @auth directive
I noticed @auth directive on top of Language type
@auth (
add: { rule: “{$USER: { eq: “my_email@gmail.com ” } }”}
)
Which prevented adding new record to Language
After removing this It started to work as expected
I have to do another check if I add sufficient records to Languages will it work
I’ve stumbled on this more times than I’d like to admin
Yep I kinda confirm this is not related to your code. It’s a current issue some of us are experiencing and dgraph guys are already trying to fix it. @rarvikar
rarvikar
(Rahul Arvikar)
July 22, 2022, 2:35pm
14
Thanks @matthewmcneely and @Leave_Trails !
Hi @Loic_Veillard , we are actively investigating the issue from this thread but I think the issue reported here was resolved as per this comment . But please let me know if that is not correct.
Yes! But i was reffering to this comment: