Skip to content

Commit

Permalink
Merge branch 'master' into remote-relationship-validation-bug-5133
Browse files Browse the repository at this point in the history
  • Loading branch information
codingkarthik authored Aug 21, 2020
2 parents a34913f + b93da39 commit d4e2955
Show file tree
Hide file tree
Showing 49 changed files with 451 additions and 84 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

- server: allow remote relationships joining `type` column with `[type]` input argument as spec allows this coercion (fixes #5133)

### Bug fixes and improvements

(Add entries here in the order of: server, console, cli, docs, others)

- docs: add docs page on networking with docker (close #4346) (#4811)
- cli: add missing global flags for seeds command (#5565)

## `v1.3.1-beta.1`

### Breaking change

Headers from environment variables starting with `HASURA_GRAPHQL_` are not allowed
Expand Down Expand Up @@ -69,7 +78,6 @@ If you do have such headers configured, then you must update the header configur

## `v1.3.0-beta.3`


### Bug fixes and improvements

(Add entries here in the order of: server, console, cli, docs, others)
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
const completionCmdExample = `# Bash
# Linux
# Add Bash completion file using:
$ sudo hasura completion bash --file=/etc/bash.completion.d/hasura
$ sudo hasura completion bash --file=/etc/bash_completion.d/hasura
# Mac
# Install bash-completion using homebrew:
$ brew install bash-completion
Expand Down
22 changes: 15 additions & 7 deletions cli/commands/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"github.com/hasura/graphql-engine/cli"
"github.com/hasura/graphql-engine/cli/util"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand All @@ -28,14 +29,21 @@ func NewSeedCmd(ec *cli.ExecutionContext) *cobra.Command {
newSeedCreateCmd(ec),
newSeedApplyCmd(ec),
)
seedCmd.PersistentFlags().String("endpoint", "", "http(s) endpoint for Hasura GraphQL Engine")
seedCmd.PersistentFlags().String("admin-secret", "", "admin secret for Hasura GraphQL Engine")
seedCmd.PersistentFlags().String("access-key", "", "access key for Hasura GraphQL Engine")
seedCmd.PersistentFlags().MarkDeprecated("access-key", "use --admin-secret instead")

v.BindPFlag("endpoint", seedCmd.PersistentFlags().Lookup("endpoint"))
v.BindPFlag("admin_secret", seedCmd.PersistentFlags().Lookup("admin-secret"))
v.BindPFlag("access_key", seedCmd.PersistentFlags().Lookup("access-key"))
f := seedCmd.PersistentFlags()

f.String("endpoint", "", "http(s) endpoint for Hasura GraphQL Engine")
f.String("admin-secret", "", "admin secret for Hasura GraphQL Engine")
f.String("access-key", "", "access key for Hasura GraphQL Engine")
f.MarkDeprecated("access-key", "use --admin-secret instead")
f.Bool("insecure-skip-tls-verify", false, "skip TLS verification and disable cert checking (default: false)")
f.String("certificate-authority", "", "path to a cert file for the certificate authority")

util.BindPFlag(v, "endpoint", f.Lookup("endpoint"))
util.BindPFlag(v, "admin_secret", f.Lookup("admin-secret"))
util.BindPFlag(v, "access_key", f.Lookup("access-key"))
util.BindPFlag(v, "insecure_skip_tls_verify", f.Lookup("insecure-skip-tls-verify"))
util.BindPFlag(v, "certificate_authority", f.Lookup("certificate-authority"))

return seedCmd
}
2 changes: 1 addition & 1 deletion cli/commands/seed_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func newSeedCreateCmd(ec *cli.ExecutionContext) *cobra.Command {
}
cmd := &cobra.Command{
Use: "create seed_name",
Short: "create a new seed file",
Short: "Create a new seed file",
Example: ` # Create a new seed file and use editor to add SQL:
hasura seed create new_table_seed
Expand Down
14 changes: 11 additions & 3 deletions console/cypress/integration/data/modify/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,20 @@ export const passModifyPkey = () => {
cy.get(getElementFromAlias('modify-table-edit-pks')).click();
cy.get(getElementFromAlias('primary-key-select-1')).select('1');
cy.get(getElementFromAlias('modify-table-pks-save')).click();
cy.get(getElementFromAlias('pk-config-text')).within(() => {
cy.get('b').contains(getColName(0));
cy.get('b').contains('id');
});
cy.wait(5000);
// TODO
// test disappearance expect
// (cy.get(getElementFromAlias('modify-table-column-1-remove'))).not.to.exist;

cy.get(getElementFromAlias('remove-pk-column-1')).click();
cy.get(getElementFromAlias('modify-table-pks-save')).click();
cy.get(getElementFromAlias('pk-config-text')).within(() => {
cy.get('b').contains('id');
});
cy.get(getElementFromAlias('pk-config-text')).within(() => {
cy.get('b').should('not.contain', getColName(0));
});
cy.get(getElementFromAlias('modify-table-close-pks')).click();
cy.wait(3000);
};
Expand Down
1 change: 0 additions & 1 deletion console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"build": "webpack --progress -p --colors --display-error-details --config webpack/prod.config.js",
"server-build": "make server-build",
"build-unused": "webpack --verbose --colors --display-error-details --config webpack/prod.config.js --json | webpack-unused -s src",
"postinstall": "webpack --display-error-details --config webpack/prod.config.js",
"cypress": "cypress open",
"test": "cypress run --spec 'cypress/integration/**/**/test.ts' --key $CYPRESS_KEY --parallel --record",
"lint": "eslint -c .eslintrc src --ext .js,.ts,.tsx",
Expand Down
18 changes: 9 additions & 9 deletions console/src/components/Services/Data/RawSQL/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ const executeSQL = (isMigration, migrationName, statementTimeout) => (

const { isTableTrackChecked, isCascadeChecked, sql } = getState().rawSQL;
const { migrationMode, readOnlyMode } = getState().main;
const isStatementTimeout = statementTimeout && !isMigration;

const migrateUrl = returnMigrateUrl(migrationMode);

let url = Endpoints.rawSQL;

const schemaChangesUp = [];

if (statementTimeout && !isMigration) {
if (isStatementTimeout) {
schemaChangesUp.push(
getRunSqlQuery(
getStatementTimeoutSql(statementTimeout),
Expand Down Expand Up @@ -111,7 +112,10 @@ const executeSQL = (isMigration, migrationName, statementTimeout) => (
}
dispatch(showSuccessNotification('SQL executed!'));
dispatch(fetchDataInit()).then(() => {
dispatch({ type: REQUEST_SUCCESS, data });
dispatch({
type: REQUEST_SUCCESS,
data: data && (isStatementTimeout ? data[1] : data[0]),
});
});
dispatch(fetchTrackedFunctions());
},
Expand Down Expand Up @@ -168,11 +172,7 @@ const rawSQLReducer = (state = defaultState, action) => {
lastSuccess: null,
};
case REQUEST_SUCCESS:
if (
action.data &&
action.data[0] &&
action.data[0].result_type === 'CommandOk'
) {
if (action.data && action.data.result_type === 'CommandOk') {
return {
...state,
ongoingRequest: false,
Expand All @@ -188,8 +188,8 @@ const rawSQLReducer = (state = defaultState, action) => {
lastError: null,
lastSuccess: true,
resultType: 'tuples',
result: action.data[0].result.slice(1),
resultHeaders: action.data[0].result[0],
result: action.data.result.slice(1),
resultHeaders: action.data.result[0],
};
case REQUEST_ERROR:
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ const PrimaryKeyEditor = ({
);

// label next to the button when the editor is expanded
const pkEditorExpandedLabel = () => <div>{pkConfigText}</div>;
const pkEditorExpandedLabel = () => (
<div data-test="pk-config-text">{pkConfigText}</div>
);

// expanded editor content
const pkEditorExpanded = () => (
Expand Down Expand Up @@ -95,7 +97,9 @@ const PrimaryKeyEditor = ({
);
};

useEffect(setPkEditState, [columns]);
useEffect(() => {
setPkEditState();
}, [columns.length]);

// remove
const onRemove = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ class Permissions extends Component {
'Backend only',
tooltip,
backendStatus,
'https://docs.hasura.io/1.0/graphql/manual/auth/authorization/permission-rules.html#backend-only-inserts'
'https://hasura.io/docs/1.0/graphql/manual/auth/authorization/permission-rules.html#backend-only'
)}
useDefaultTitleStyle
testId={'toggle-backend-only'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const RedeliverEvent: React.FC<Props> = ({ dispatch, eventId }) => {
resizable
manual
showPagination={false}
freezeWhenExpanded
SubComponent={(logRow: any) => {
const finalIndex = logRow.index;
const finalRow = logs[finalIndex];
Expand Down
5 changes: 5 additions & 0 deletions docs/_theme/djangodocs/basic/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ <h3>{{ _('Navigation') }}</h3>
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PF5MQ2Z');</script>
<!-- End Google Tag Manager -->
<!-- Posthog -->
<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('a1dops3FFe8KioWsry6W6AVqCG_j-FXmw1LY2d6TrYU', {api_host: 'https://cloud-posthog.hasura-app.io'})
</script>
{%- if use_opensearch %}
<link rel="search" type="application/opensearchdescription+xml"
title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}"
Expand Down
5 changes: 5 additions & 0 deletions docs/graphql/manual/actions/create.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ Now, set the handler for the action:
e.g. ``https://my-handler-endpoint/addNumbers`` can be templated to ``{{ACTION_BASE_ENDPOINT}}/addNumbers``
where ``ACTION_BASE_ENDPOINT`` is an ENV variable whose value is set to ``https://my-handler-endpoint``

.. note::

If you are running Hasura using Docker, ensure that the Hasura Docker container can reach the handler endpoint.
See :ref:`this page <docker_networking>` for Docker networking.

Step 3: Finish action creation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion docs/graphql/manual/actions/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enrichment from external sources and any other complex business logic.
:class: no-shadow
:alt: Actions high level architecture

.. admonition:: Support
.. admonition:: Supported from

Actions are supported in Hasura GraphQL engine versions ``v.1.2.0`` and above.

Expand Down
2 changes: 1 addition & 1 deletion docs/graphql/manual/actions/types/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Relationships
*************

Custom object types can be connected to the rest of the graph by setting up
:ref:`table relationships <table_relationships>` with tables/views.
:ref:`action relationships <action_relationships>` with tables/views.

**For example**, given the object type:

Expand Down
5 changes: 5 additions & 0 deletions docs/graphql/manual/auth/authentication/webhook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ Configuring webhook mode

* You can configure Hasura to send either a ``GET`` or a ``POST`` request to your auth webhook. The default configuration is ``GET`` and you can override this with ``POST`` by using the ``--auth-hook-mode`` flag or the ``HASURA_GRAPHQL_AUTH_HOOK_MODE`` environment variable (*in addition to those specified above; see* :ref:`GraphQL engine server options <server_flag_reference>`).

.. note::

If you are running Hasura using Docker, ensure that the Hasura Docker container can reach the webhook.
See :ref:`this page <docker_networking>` for Docker networking.

Spec for the webhook
--------------------

Expand Down
5 changes: 5 additions & 0 deletions docs/graphql/manual/event-triggers/create-trigger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ The HTTP(s) URL which will be called with the event payload on configured operat
can be entered manually or can be picked up from an environment variable (*the environment variable needs to be set
before using it for this configuration*).

.. note::

If you are running Hasura using Docker, ensure that the Hasura Docker container can reach the webhook.
See :ref:`this page <docker_networking>` for Docker networking.

Advanced Settings
-----------------

Expand Down
118 changes: 118 additions & 0 deletions docs/graphql/manual/guides/docker-networking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
.. meta::
:description: Docker networking with Hasura
:keywords: hasura, docs, deployment, network, docker

.. _docker_networking:

Docker networking
=================

.. contents:: Table of contents
:backlinks: none
:depth: 2
:local:

Introduction
------------

Sometimes you might want to connect Hasura with APIs (e.g. auth webhooks, event triggers, remote schemas) that are either running outside of Docker or in a different Docker container.
Depending on the setting, the network config is different. This section shows how to connect in each of these use cases.

Network config
--------------

.. rst-class:: api_tabs
.. tabs::

.. tab:: Linux

.. list-table::
:stub-columns: 1
:header-rows: 1

* - Connection
- Config
- Comment
* - **Hasura to API (outside Docker)**
- 1. With ``--net=host``, e.g. ``localhost:3000 --net=host``
2. Otherwise, ``<docker-bridge-ip>:3000``, e.g. ``172.17.0.1:3000``
- 1. Assuming the API is running on port ``3000``
2. The Docker bridge IP can be found via ``ifconfig``
* - **API (outside Docker) to Hasura**
- ``localhost:8080``
- Hasura runs on port ``8080`` by default
* - **Hasura to API (both in docker-compose)**
- service name, e.g.: ``api:3000``
- Assuming the API is running on port ``3000``
* - **API to Hasura (both in docker-compose)**
- service name, e.g.: ``hasura:8080``
- Hasura runs on port ``8080`` by default
* - **Hasura to API (both running with separate docker run)**
- Docker internal IP address
- Can be obtained with ``docker inspect``
* - **API to Hasura (both running with separate docker run)**
- Docker internal IP address
- Can be obtained with ``docker inspect``

.. tab:: Mac

.. list-table::
:stub-columns: 1
:header-rows: 1


* - Connection
- Config
- Comment
* - **Hasura to API (outside Docker)**
- ``host.docker.internal:3000``
- Assuming the API is running on port ``3000``
* - **API (outside Docker) to Hasura**
- ``localhost:8080``
- Hasura runs on port ``8080`` by default
* - **Hasura to API (both in docker-compose)**
- service name, e.g.: ``api:3000``
- Assuming the API is running on port ``3000``
* - **API to Hasura (both in docker-compose)**
- service name, e.g.: ``hasura:8080``
- Hasura runs on port ``8080`` by default
* - **Hasura to API (both running with separate docker run)**
- Docker internal IP address
- Can be obtained with ``docker inspect``
* - **API to Hasura (both running with separate docker run)**
- Docker internal IP address
- Can be obtained with ``docker inspect``


.. tab:: Windows

.. list-table::
:stub-columns: 1
:header-rows: 1

* - Connection
- Config
- Comment
* - **Hasura to API (outside Docker)**
- ``docker.for.win.localhost:3000``
- Assuming the API is running on port ``3000``
* - **API (outside Docker) to Hasura**
- ``localhost:8080``
- Hasura runs on port ``8080`` by default
* - **Hasura to API (both in docker-compose)**
- service name, e.g.: ``api:3000``
- Assuming the API is running on port ``3000``
* - **API to Hasura (both in docker-compose)**
- service name, e.g.: ``hasura:8080``
- Hasura runs on port ``8080`` by default
* - **Hasura to API (both running with separate docker run)**
- Docker internal IP address
- Can be obtained with ``docker inspect``
* - **API to Hasura (both running with separate docker run)**
- Docker internal IP address
- Can be obtained with ``docker inspect``

Advanced
--------

Learn more about Docker specific networking in the `Docker documentation <https://docs.docker.com/network/>`__.
1 change: 1 addition & 0 deletions docs/graphql/manual/guides/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Guides / Tutorials / Resources
:titlesonly:

Data modelling guides <data-modelling/index>
Docker networking <docker-networking>
Sample apps & boilerplates <sample-apps/index>
Integration/migration tutorials <integrations/index>
Integrating with monitoring frameworks <monitoring/index>
Expand Down
Loading

0 comments on commit d4e2955

Please sign in to comment.