Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document the relational insert feature #1310

Closed
0x777 opened this issue Jan 4, 2019 · 6 comments
Closed

document the relational insert feature #1310

0x777 opened this issue Jan 4, 2019 · 6 comments
Assignees
Labels
c/docs Related to docs e/intermediate can be wrapped up in a week p/high candidate for being included in the upcoming sprint

Comments

@0x777
Copy link
Member

0x777 commented Jan 4, 2019

Currently we just have this one example at https://docs.hasura.io/1.0/graphql/manual/mutations/insert.html#insert-an-object-and-its-nested-object-in-the-same-mutation

@0x777 0x777 added c/docs Related to docs p/high candidate for being included in the upcoming sprint labels Jan 4, 2019
@rikinsk-zz
Copy link

@0x777 Are you looking for more explanation or better visibility?
This is also repeated at https://docs.hasura.io/1.0/graphql/manual/mutations/multiple-mutations.html#insert-an-object-and-a-nested-object-in-the-same-mutation

@0x777
Copy link
Member Author

0x777 commented Jan 4, 2019

Explanation, for example, what is update_columns/constraint etc. Few examples with many-to-many relationships too will help.

@rikinsk-zz
Copy link

  • adding multiple nested objects in case of array relationships
  • passing arguments to nested insert (eg. on_conflict)

@marionschleifer marionschleifer added the e/intermediate can be wrapped up in a week label Jul 10, 2019
@marionschleifer marionschleifer self-assigned this Jul 10, 2019
@dohomi
Copy link

dohomi commented Sep 4, 2019

any update on this? Currently its a huge grey zone how insert/updates of relations in general works. I have a 1:1 relation of users => client setup and have a hard time to get the statement up and running.

mutation{
  insert_users(
    objects:[
      {
        email:"test"
        password:"test"
        role:"client",
        first_name:"test"
        client:{
    	  data:{
            placement_status_id:1
          }
        }
      }
    ]
  ){
    affected_rows
  }
}

I receive an error

{
  "errors": [
    {
      "extensions": {
        "path": "$.selectionSet.insert_users.args.objects[0]",
        "code": "constraint-violation"
      },
      "message": "Not-NULL violation. null value in column \"id\" violates not-null constraint"
    }
  ]
}

@lishine
Copy link

lishine commented Sep 4, 2019

What is your id field type?

@rikinsk
Copy link
Member

rikinsk commented Sep 4, 2019

@lishine this is a current limitation of nested inserts for 1-1 relationships. Its being tracked at #2576.

hasura-bot pushed a commit that referenced this issue Nov 4, 2024
Bumps [derive_more](https://github.com/JelteF/derive_more) from 0.99.18
to 1.0.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/JelteF/derive_more/releases">derive_more's
releases</a>.</em></p>
<blockquote>
<h2>v1.0.0 - Finally a stable release</h2>
<p><code>derive_more</code> is a library that adds derives for many of
the standard library traits. By using this library the following code
just works:</p>
<pre lang="rust"><code>use derive_more::{Add, Display, From, Into};
<p>#[derive(PartialEq, From, Add)]
struct MyInt(i32);</p>
<p>#[derive(PartialEq, From, Into)]
struct Point2D {
x: i32,
y: i32,
}</p>
<p>#[derive(PartialEq, From, Add, Display)]
enum MyEnum {
#[display(&quot;int: {_0}&quot;)]
Int(i32),
Uint(u32),
#[display(&quot;nothing&quot;)]
Nothing,
}</p>
<p>assert!(MyInt(11) == MyInt(5) + 6.into());
assert!((5, 6) == Point2D { x: 5, y: 6 }.into());
assert!(MyEnum::Int(15) == (MyEnum::Int(8) + 7.into()).unwrap());
assert!(MyEnum::Int(15).to_string() == &quot;int: 15&quot;);
assert!(MyEnum::Uint(42).to_string() == &quot;42&quot;);
assert!(MyEnum::Nothing.to_string() == &quot;nothing&quot;);
</code></pre></p>
<p>Now, more than 8 years after the first commit and almost 5 years
after the 0.99.0 release, <code>derive_more</code> has finally reached
its 1.0.0 release. This release contains a lot of changes (including
some breaking ones) to make it easier to use the derives and make it
possible to extend them without having to break backwards compatibility
again. There are five major changes that I would like to call out, but
there are many more changes that are documented below:</p>
<ol>
<li>There is a new <code>Debug</code> derive that can be used to easily
customize <code>Debug</code> formatting.</li>
<li>A greatly improved <code>Display</code> derive, which allows you to
do anything that <a
href="https://github.com/dtolnay/thiserror"><code>thiserror</code></a>
provides, but it works for any type not just errors. And by combining
the <code>Display</code> derive with the <code>Error</code> and
<code>From</code> derives, there shouldn't really be any need to use
<code>thiserror</code> anymore (if you are missing a feature/behaviour
from <code>thiserror</code> please report an issue).</li>
<li>Traits that can return errors now return a type that implements
<code>Error</code> when an error occurs instead of a <code>&amp;'static
str</code>.</li>
<li>When using <code>use derive_more::SomeTrait</code> the actual trait
is also imported not just the derive macro. This is especially useful
for <code>Error</code> and
<code>Display</code></li>
<li>The docs are now rendered on docs.rs and are much better
overall.</li>
</ol>
<h3>Breaking changes</h3>
<ul>
<li>The minimum supported Rust version (MSRV) is now Rust 1.75.</li>
<li>Add the <code>std</code> feature which should be disabled in
<code>no_std</code> environments.</li>
<li>All Cargo features, except <code>std</code>, are now disabled by
default. The <code>full</code> feature can be used to get the old
behavior of supporting all possible derives.</li>
<li>The <code>TryFrom</code>, <code>Add</code>, <code>Sub</code>,
<code>BitAnd</code>, <code>BitOr</code>, <code>BitXor</code>,
<code>Not</code> and <code>Neg</code> derives now return a dedicated
error type instead of a <code>&amp;'static str</code> on error.</li>
<li>The <code>FromStr</code> derive now uses a dedicated
<code>FromStrError</code> error type instead of generating unique one
each time.</li>
<li>The <code>Display</code> derive (and other <code>fmt</code>-like
ones) now uses <code>#[display(&quot;...&quot;,
(&lt;expr&gt;),*)]</code> syntax instead of <code>#[display(fmt =
&quot;...&quot;, (&quot;&lt;expr&gt;&quot;),*)]</code>, and
<code>#[display(bound(&lt;bound&gt;))]</code> instead of
<code>#[display(bound = &quot;&lt;bound&gt;&quot;)]</code>. So without
the double quotes around the expressions and bounds.</li>
<li>The <code>Debug</code> and <code>Display</code> derives (and other
<code>fmt</code>-like ones) now transparently delegate to the inner type
when <code>#[display(&quot;...&quot;, (&lt;expr&gt;),*)]</code>
attribute is trivially substitutable with a transparent call. (<a
href="https://redirect.github.com/JelteF/derive_more/pull/322">#322</a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/JelteF/derive_more/blob/master/CHANGELOG.md">derive_more's
changelog</a>.</em></p>
<blockquote>
<h2>1.0.0 - 2024-08-07</h2>
<p>More than 8 years after the first commit and almost 5 years after the
0.99.0
release, <code>derive_more</code> has finally reached its 1.0.0 release.
This release
contains a lot of changes (including some breaking ones) to make it
easier to
use the derives and make it possible to extend them without having to
break
backwards compatibility again. There are five major changes that I would
like
to call out, but there are many more changes that are documented
below:</p>
<ol>
<li>There is a new <code>Debug</code> derive that can be used to easily
customize <code>Debug</code>
formatting.</li>
<li>A greatly improved <code>Display</code> derive, which allows you to
do anything that
<a
href="https://github.com/dtolnay/thiserror"><code>thiserror</code></a>
provides, but it works
for any type not just errors. And by combining the <code>Display</code>
derive with the
<code>Error</code> and <code>From</code> derives, there shouldn't really
be any need to use
<code>thiserror</code> anymore (if you are missing a feature/behaviour
from <code>thiserror</code>
please report an issue).</li>
<li>Traits that can return errors now return a type that implements
<code>Error</code>
when an error occurs instead of a <code>&amp;'static str</code>.</li>
<li>When using <code>use derive_more::SomeTrait</code> the actual trait
is also imported
not just the derive macro. This is especially useful for
<code>Error</code> and
<code>Display</code></li>
<li>The docs are now rendered on docs.rs and are much better
overall.</li>
</ol>
<h3>Breaking changes</h3>
<ul>
<li>The minimum supported Rust version (MSRV) is now Rust 1.75.</li>
<li>Add the <code>std</code> feature which should be disabled in
<code>no_std</code> environments.</li>
<li>All Cargo features, except <code>std</code>, are now disabled by
default. The <code>full</code>
feature can be used to get the old behavior of supporting all possible
derives.</li>
<li>The <code>TryFrom</code>, <code>Add</code>, <code>Sub</code>,
<code>BitAnd</code>, <code>BitOr</code>, <code>BitXor</code>,
<code>Not</code> and <code>Neg</code>
derives now return a dedicated error type instead of a
<code>&amp;'static str</code> on
error.</li>
<li>The <code>FromStr</code> derive now uses a dedicated
<code>FromStrError</code> error type instead
of generating unique one each time.</li>
<li>The <code>Display</code> derive (and other <code>fmt</code>-like
ones) now uses
<code>#[display(&quot;...&quot;, (&lt;expr&gt;),*)]</code> syntax
instead of
<code>#[display(fmt = &quot;...&quot;,
(&quot;&lt;expr&gt;&quot;),*)]</code>, and
<code>#[display(bound(&lt;bound&gt;))]</code>
instead of <code>#[display(bound = &quot;&lt;bound&gt;&quot;)]</code>.
So without the double quotes
around the expressions and bounds.</li>
<li>The <code>Debug</code> and <code>Display</code> derives (and other
<code>fmt</code>-like ones) now transparently
delegate to the inner type when <code>#[display(&quot;...&quot;,
(&lt;expr&gt;),*)]</code> attribute is
trivially substitutable with a transparent call.
(<a
href="https://redirect.github.com/JelteF/derive_more/pull/322">#322</a>)</li>
<li>The <code>DebugCustom</code> derive is renamed to just
<code>Debug</code> (gated now under a separate
<code>debug</code> feature), and its semantics were changed to be a
superset of <code>std</code> variant
of <code>Debug</code>.</li>
<li>The <code>From</code> derive doesn't derive
<code>From&lt;()&gt;</code> for enum variants without any
fields anymore. This feature was removed because it was considered
useless in</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/JelteF/derive_more/commit/d7f5b9e94d024790682f6fc4dcca13941cce64c8"><code>d7f5b9e</code></a>
chore: Release</li>
<li><a
href="https://github.com/JelteF/derive_more/commit/40201b1e2e39d449f998d57e1a8471f5bab0b069"><code>40201b1</code></a>
Update release date to be correct</li>
<li><a
href="https://github.com/JelteF/derive_more/commit/88863ca4e69eb11ac0f476c6afca45fe57bd6576"><code>88863ca</code></a>
Update changelog wording</li>
<li><a
href="https://github.com/JelteF/derive_more/commit/b713835894454cd0246dd80e13ce72cb056c82b0"><code>b713835</code></a>
Improve error when not enabling any features</li>
<li><a
href="https://github.com/JelteF/derive_more/commit/330e4252fbc12e41794f7f5e164e96423f6f9ff1"><code>330e425</code></a>
Order features in Cargo.toml alphabetically</li>
<li><a
href="https://github.com/JelteF/derive_more/commit/84f2cbb05fc7cefb433144b3f86a85c0bc3e339b"><code>84f2cbb</code></a>
Update README and CHANGELOG in preparation of 1.0.0</li>
<li><a
href="https://github.com/JelteF/derive_more/commit/e8d60cf0e5c4ef21ffb96617b5be160990c56741"><code>e8d60cf</code></a>
Add compile_fail test for on purpose limited bounds (<a
href="https://redirect.github.com/JelteF/derive_more/issues/393">#393</a>,
<a
href="https://redirect.github.com/JelteF/derive_more/issues/392">#392</a>)</li>
<li><a
href="https://github.com/JelteF/derive_more/commit/f665d18125e3b7eba34e71a3e6d20060a05c41a7"><code>f665d18</code></a>
Make anyhow reference a bit less strong</li>
<li><a
href="https://github.com/JelteF/derive_more/commit/6d632b2db29d138f72f5fbc3023972d0b00ed614"><code>6d632b2</code></a>
Add release announcement (<a
href="https://redirect.github.com/JelteF/derive_more/issues/390">#390</a>)</li>
<li><a
href="https://github.com/JelteF/derive_more/commit/e87ab1315f01223eb20b232ca5a9294285d7b993"><code>e87ab13</code></a>
Don't create git tags for derive_more-impl (<a
href="https://redirect.github.com/JelteF/derive_more/issues/391">#391</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/JelteF/derive_more/compare/v0.99.18...v1.0.0">compare
view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=derive_more&package-manager=cargo&previous-version=0.99.18&new-version=1.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)

</details>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Daniel Harvey <[email protected]>
V3_GIT_ORIGIN_REV_ID: 2a5d2033a90d16d5bf2096db5a717e31128b8c00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/docs Related to docs e/intermediate can be wrapped up in a week p/high candidate for being included in the upcoming sprint
Projects
None yet
Development

No branches or pull requests

6 participants