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

Conversation

@jberryman
Copy link
Collaborator

Description

Support tracking functions as mutations (top-level fields under mutation root field). Support is added to the v2 API while remaining backwards compatible. See comments for API design decisions.

This is the second version of this feature implemented. The first is at: #5858

  • new field (replacing as_mutation): expose_as: query or expose_as: mutation
    • if included we'll place the function where requested, regardless of its volatility
    • ...with the exception that non-volatile functions requested exposed as mutations will raise an error, since this probably indicates a mistake either in choice of function, or when defining the function
    • we'll raise a warning in some way whenever the volatility and expose_as are "mismatched" UPDATE: I punted on this
  • if that field is omitted, we'll infer expose_as from the volatility (VOLATILE implies mutation, otherwise query)

Changelog

  • CHANGELOG.md is updated with user-facing content relevant to this PR. If no changelog is required, then add the no-changelog-required label.

Affected components

  • Server
  • Console
  • CLI
  • Docs
  • Community Content
  • Build System
  • Tests
  • Other (list it)

Related Issues

#1514

Solution and Design

I re-used the machinery from support for tracking functions as queries and tried to do as little as possible.

Steps to test and verify

The tests written here represent the extent that I've tested/tried this out, so you can run those.

Limitations, known bugs & workarounds

The tests aren't particularly thorough; since so much of the queries code is re-used this seems all right to me.

Aggregations on the result set isn't implemented; it might be as simple as uncommenting the relevant line (I just noticed this as an unresolved question).

Server checklist

Catalog upgrade

Does this PR change Hasura Catalog version?

  • No
  • Yes
    • Updated docs with SQL for downgrading the catalog

Metadata

Does this PR add a new Metadata feature?

  • No
  • Yes
    • Does run_sql auto manages the new metadata through schema diffing?
      • Yes
      • Not required
    • Does run_sql auto manages the definitions of metadata on renaming?
      • Yes
      • Not required
    • Does export_metadata/replace_metadata supports the new metadata added?
      • Yes
      • Not required

GraphQL

  • No new GraphQL schema is generated
  • New GraphQL schema is being generated:
    • New types and typenames are correlated

Breaking changes

  • No Breaking changes

  • There are breaking changes:

    1. Metadata API

      Existing query types:

      • Modify args payload which is not backward compatible
      • Behavioural change of the API
      • Change in response JSON schema
      • Change in error code
    2. GraphQL API

      Schema Generation:

      • Change in any NamedType
      • Change in table field names

      Schema Resolve:-

      • Change in treatment of null value for any input fields
    3. Logging

      • Log JSON schema has changed
      • Log type names have changed

@netlify
Copy link

netlify bot commented Nov 10, 2020

Deploy preview for hasura-docs ready!

Built with commit 7e9a2eb

https://deploy-preview-6160--hasura-docs.netlify.app

@tirumaraiselvan tirumaraiselvan added this to the v1.4 milestone Nov 10, 2020
Copy link
Contributor

@abooij abooij left a comment

Choose a reason for hiding this comment

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

Thanks, Brandon, this is a really nice PR, and I hope you manage to merge this soon. I have lefta few notes for you to use as you wish - from my point of view they're not blockers.

Are you sure you want to tell kodiak to "merge" this PR, rather than "squash" it (which is the default if you only apply the auto-update-auto-merge label)?

@kodiakhq
Copy link
Contributor

kodiakhq bot commented Nov 11, 2020

This PR currently has a merge conflict. Please resolve this and then re-add the auto-update-auto-merge label.

This also supports tracking VOLATILE functions as queries.

Review and discussion of the initial version of this work can be found
in this closed PR:

hasura#5858
...after we needed to re-use some Query.hs code in Mutate.hs
No implementation changes.

With the state of documentation of this part of the code it's hard to
say whether this is moving towards a better module structure or is just
an arbitrary change.
@jberryman jberryman force-pushed the 1514-sql-function-mutations-v2 branch from 7078b3a to 8c09e42 Compare November 12, 2020 21:04
@jberryman
Copy link
Collaborator Author

Are you sure you want to tell kodiak to "merge" this PR, rather than "squash" it (which is the default if you only apply the auto-update-auto-merge label)?

yep

@hasura-bot
Copy link
Contributor

Thanks for your contribution! Your changes have been merged successfully.

hasura-bot added a commit that referenced this pull request Nov 18, 2020
* Support tracking SQL functions as mutations. Closes #1514

Co-authored-by: Brandon Simmons <brandon.m.simmons@gmail.com>
Co-authored-by: Brandon Simmons <brandon@hasura.io>
GITHUB_PR_NUMBER: 6160
GITHUB_PR_URL: #6160

* Update docs/graphql/core/api-reference/schema-metadata-api/custom-functions.rst

Co-authored-by: Marion Schleifer <marion@hasura.io>

* Update docs/graphql/core/schema/custom-functions.rst

Co-authored-by: Marion Schleifer <marion@hasura.io>

* Update docs/graphql/core/schema/custom-functions.rst

Co-authored-by: Marion Schleifer <marion@hasura.io>

* Update docs/graphql/core/schema/custom-functions.rst

Co-authored-by: Brandon Simmons <brandon@hasura.io>
Co-authored-by: Brandon Simmons <brandon.m.simmons@gmail.com>
Co-authored-by: Marion Schleifer <marion@hasura.io>
GitOrigin-RevId: 8fd3925
@hasura-bot hasura-bot closed this Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants