How do I write a mutation with a linked relationship?

Hi all -

I have a pretty typical schema for a blog.

type User {
    id:            ID!                      
    userID:        String!                  @search(by: [exact, regexp])
    email:         String!                  @search(by: [term, regexp])
    username:      String!                  @id
    avatar:        String                   
    displayName:   String!                  @search(by: [term, regexp])
    phone:         String                   
    city:          City                     
    birthday:      DateTime                 
    tagline:       String                   
    bio:           String                   
    hasBlogs: [Blog]  @hasInverse(field: author) 

type City {
    id:            ID!                      
    name:          String!                  
    state:         State                   

type State {
    name:          String!                  @id
    cities:        [City]                   @hasInverse(field: state)

type Blog {
    id: ID!
    author: User! 
    imageUrl: String
    post: String!
    createdDate: DateTime!

I used the explored to write my mutation and I this is what I sent:

mutation MyMutation {
  addBlog(input: {post: "Lorem ipsum", createdDate: "2020-10-12T23:20:50.52Z", author: {userID: "XXXXXXXXXXX"}, imageUrl: ""}) {
    blog {

I get this error:

  "errors": [
      "message": "Value provided {post:\"Lorem ipsum\",createdDate:\"2020-10-12T23:20:50.52Z\",author:{userID:\"XXXXXXXXXXXX\"},imageUrl:\"\"} is incompatible with expected type [AddBlogInput!]!",
      "locations": [
          "line": 2,
          "column": 18

I’m not 100% sure, but I suspect that it’s expecting me to supply EVERY User property as docs look like this:



Can someone either tell me what I’m doing wrong or clarify… Do I really have to submit every property to make this work?

There is a bug in the builder… use an array for the input containing the object

1 Like