这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@rakeshkky
Copy link
Member

@rakeshkky rakeshkky commented Sep 12, 2018

examples:
Insert author along with it's articles (inserting array relationship)

   mutation nested_author_insert {
      insert_author(
        objects: [
          {
            name: "Author 3", 
            articles: {
              data: [
                {
                  title: "An article by author 3", 
                  content: "Content for article by author 3", 
                  is_published: false
                }
              ]
            }
          }
        ]
      ) {
        affected_rows
        returning {
          id
          name
          articles {
            id
          }
        }
      }
   }

Insert articles along with author (inserting object relationship)

   mutation article_author{
     insert_article(
       objects: [
         {
           title: "Article by author 4",
           content: "Article content for article by author 4",
           is_published: true
           author: {
             data: {
               name: "Article 4"
             }
           }
         },
         {
           title: "Article by author 5",
           content: "Article content for article by author 5",
           is_published: true
           author: {
             data: {
               name: "Article 5"
             }
           }
         }
       ]
     ){
       affected_rows
       returning{
         id
         title
         content
         author{
           id
           name
         }
       }
     }
   }

@rakeshkky rakeshkky added the c/server Related to server label Sep 12, 2018
@rakeshkky rakeshkky self-assigned this Sep 12, 2018
@rakeshkky rakeshkky requested a review from 0x777 September 12, 2018 12:18
@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

G.NamedType $ qualTableToName tn <> "_insert_input"

-- table_relname_obj_insert_input
mkObjInsInpTy :: QualifiedTable -> RelName -> G.NamedType
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These types don't need to be generated per (table, rel). They can be as follows:

input table_insert_input {
  ..
}
input table_obj_rel_insert_input {
  data table_insert_input!
  on_conflict table_on_conflict!
}
input table_arr_rel_insert_input {
  data [table_insert_input!]!
  on_conflict table_on_conflict!
}

@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

1 similar comment
@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

-> if no relations given, insert all objects at one go
-> if no array relations to insert, generate with expression as normal
   insert, else insert object and generate with expression as select
   from table using array relation left cols values in where expression
@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

@shahidhk shahidhk added the s/do-not-merge Do not merge this pull request to master label Oct 2, 2018
Resolve Conflicts:
	server/src-lib/Hasura/RQL/DML/Select.hs
	server/src-lib/Hasura/RQL/Types.hs
	server/src-lib/Hasura/SQL/DML.hs
@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

@shahidhk shahidhk changed the title nested mutations for inserting related objects (close #343) insert mutations now handle nested-data/relationsips (close #343) Oct 5, 2018
@shahidhk shahidhk changed the title insert mutations now handle nested-data/relationsips (close #343) mutations now insert nested-data/relationsips (close #343) Oct 5, 2018
@shahidhk shahidhk changed the title mutations now insert nested-data/relationsips (close #343) insert_mutations can now insert nested-data/relationsips (close #343) Oct 5, 2018
@shahidhk shahidhk changed the title insert_mutations can now insert nested-data/relationsips (close #343) insert mutations can now handle nested-data/relationsips (close #343) Oct 5, 2018
@shahidhk shahidhk added s/ok-to-merge Status: This pull request can be merged to master and removed s/do-not-merge Do not merge this pull request to master labels Oct 5, 2018
@hasura-bot
Copy link
Contributor

Review app available at: https://hge-ci-pull-429.herokuapp.com

@shahidhk shahidhk merged commit 00d5a5c into hasura:master Oct 5, 2018
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-429.herokuapp.com is deleted

hasura-bot pushed a commit that referenced this pull request Apr 2, 2024
V3_GIT_ORIGIN_REV_ID: b0377caff0cb6c65b51179037e09e6eae9dc3bfb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c/server Related to server s/ok-to-merge Status: This pull request can be merged to master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants