Graphql-engine: docs: add page with action examples

Created on 8 May 2020  Â·  5Comments  Â·  Source: hasura/graphql-engine

We should create a section on actions docs where we show examples.

These examples can include:

  • Different use cases
  • Different response types

    • array vs object

  • Different types of relationships

    • array vs object

  • Working with local instance of an action handler
  • URL templating of action handler
actions docs

Most helpful comment

I think it would be good to explain how to handle following use case:

  1. We have 3 environments, dev, staging and production
  2. It is likely that out actions will be on 3 separate environments as well, each on their own domain / subdomain
  3. As far as I can tell we can set base path with HASURA_GRAPHQL_ACTIONS_HANDLER_WEBHOOK_BASEURL

However from this point on it is not clear what this flag does, we can only assume. If I am correct we need to clarify these things

  1. If I have this flag specified does this mean I can only add specific path in my action handler i.e just /checkout or do I still need to specify full url?
  2. If I leave handler empty, can I as assume that request will be made to my baseurl?
  3. If my base url already has / at the end of it, do I need to specify it in handler?
  4. Right now even with this flag set I can still see http://host.docker.internal:3000 as default value in my handler input, perhaps it should be changed to actual flag value?

All 5 comments

I think it would be good to explain how to handle following use case:

  1. We have 3 environments, dev, staging and production
  2. It is likely that out actions will be on 3 separate environments as well, each on their own domain / subdomain
  3. As far as I can tell we can set base path with HASURA_GRAPHQL_ACTIONS_HANDLER_WEBHOOK_BASEURL

However from this point on it is not clear what this flag does, we can only assume. If I am correct we need to clarify these things

  1. If I have this flag specified does this mean I can only add specific path in my action handler i.e just /checkout or do I still need to specify full url?
  2. If I leave handler empty, can I as assume that request will be made to my baseurl?
  3. If my base url already has / at the end of it, do I need to specify it in handler?
  4. Right now even with this flag set I can still see http://host.docker.internal:3000 as default value in my handler input, perhaps it should be changed to actual flag value?

I am also having the same doubts @IljaDaderko has — and I have no clue how to move forward about this. Did you figure it out?

@XVincentX Did you figure this out. If not can you share exactly where you are stuck.

Just to clarify, the action handler should be defined as {{<ACTION_BASE_ENV_VAR>}}/<endpoint-in-the service> (<ACTION_BASE_ENV_VAR> is a placeholder for the env var you want to use) and then you can set different values for the <ACTION_BASE_ENV_VAR> in your separate environments.

I figured it out, thanks.

V.

Hey @XVincentX @rikinsk @marionschleifer Does the value I set in HASURA_GRAPHQL_ACTIONS_HANDLER_WEBHOOK_BASEURL env var gets mapped to ACTION_BASE_ENV_VAR or I can name my ENV VAR (viz MY_ENV_VAR) anything I want and the use it in mustache {{MY_ENV_VAR}} syntax. If yes what is significance of HASURA_GRAPHQL_ACTIONS_HANDLER_WEBHOOK_BASEURL env var? I still did not find any reference in hasura docs apart from this

Was this page helpful?
0 / 5 - 0 ratings