Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Disable default mutations is now in config file #89

Merged
merged 2 commits into from
May 2, 2019

Conversation

ana0
Copy link
Contributor

@ana0 ana0 commented Apr 29, 2019

Do folks think it should be an env var too?

@m0ar
Copy link
Contributor

m0ar commented Apr 30, 2019

@ana0 Hey! Personally can't find a reason to have GQL mutations at all for vDB.

This should indeed be the default, but I don't think we need this embedded postgraphile code any more. AFAIK the before-it-was-open-source subscription stuff was the only reason for using postgraphile as a library, so I think we should be able to use the postgraphile binary externally and use ye olde' CLI flags to configure everything we need 🤷‍♀️ That'd mean the only connection between vDB and postgraphile would be some README material on how to configure it (which would make @AFDudley happy 💯 )

I haven't found the time to try it our properly yet, but I think @elizabethengelman has done some tests on this?

@ana0
Copy link
Contributor Author

ana0 commented Apr 30, 2019

Veriledger needs mutations in order to add new addresses and contracts to the account transformer (just for the accounts schema), and are currently building off this branch. But if the preferred path forward is to remove the embedded postgraphile and have them build with the binary directly, that should be fine too. Someone will need to test it out and provide support to them while they set it up.

@m0ar
Copy link
Contributor

m0ar commented Apr 30, 2019

@ana0 Ah, that's cool. Then definitely go ahead with this for now. When we phase out postgraphile from this codebase it'll be easier for everyone, instead of having to build it from source etc. AFAIK one would just invokes the vanilla postgraphile binary and pass some configuration flags we would list in the README.

Copy link
Contributor

@m0ar m0ar left a comment

Choose a reason for hiding this comment

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

🚀

@@ -37,6 +38,9 @@ export function parseConfig(
gqSchemas = parsedToml['database']['gq_schemas'];
gqUser = parsedToml['database']['gq_user'] || gqUser;
gqPassword = parsedToml['database']['gq_password'] || gqPassword;
disableDefaultMutations = parsedToml['database']['disable_default_mutations'] === undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm no TS/JS wizard, what's the difference between this and the disjunctions above? I think this would behave unexpectedly on an empty string for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean if there were an empty string in the config.toml? In that case, it'll ignore the incorrect var and keep the default true. I did it this way because there are expected cases where disableDefaultMutations will be falsey.

So, if disable_default_mutations = false in the config.toml, disableDefaultMutations = parsedToml['database']['disable_default_mutations'] || true; would still end up true.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, makes sense 👌

Copy link
Collaborator

@i-norden i-norden left a comment

Choose a reason for hiding this comment

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

LGTM! I just have a single comment, not blocking.

I am definitely all for removing Postgraphile entirely from this codebase in the future, if possible.

@@ -23,8 +23,7 @@ Build the docker image in this directory. Start the `GraphiQL` frontend by:
* GraphiQL frontend is available at `:3000/graphiql`
GraphQL endpoint is available at `:3000/graphql`

By default, this build will expose only the "public" schema - to add other schemas, use either the env variables,
or a config file `config.toml` and set the env var `CONFIG_PATH` to point to its location. Example `toml`:
By default, this build will expose only the "public" schema and will disable mutations - to change mutation behaviour, you can use an optional config file `config.toml` and set the env var `CONFIG_PATH` to point to its location. Example `toml`:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't specific to this PR since CONFIG_PATH was introduced earlier, but I wonder if we should use a more specific env variable name for this? How "hard-coded" is this in Postgraphile? Seems unlikely but CONFIG_PATH is pretty generic and could potentially run into a conflict.

Gslaughl pushed a commit that referenced this pull request May 1, 2019
* Use transformer factory for Bite

- introduces separate transformer factory for non-LogNote events
- converter includes `ToEntities` for events defined via ABI

* Updates after rebasing with staging
Copy link
Contributor

@rmulhol rmulhol left a comment

Choose a reason for hiding this comment

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

This looks good to me. I am partial to Ian's comment about potentially changing the name of the environment variable if we can, but not sure if that's out of scope. Also wanted to check in on whether #90 serves our use cases - feel like it might obsolete this PR but also don't want to fire away if it turns out that folks won't be able to run postgraphile how they want without the bespoke code.

@ana0
Copy link
Contributor Author

ana0 commented May 2, 2019

I just pushed to change CONFIG_PATH to POSTGRAPHILE_CONFIG_PATH - and yes, agree that #90 is likely to obsolete this. Might be best to co-ordinate with the Veriledger team and see how they do with the stock postgraphile before closing?

@ana0 ana0 merged commit 202fb6e into staging May 2, 2019
@ana0 ana0 deleted the feature/configurableMutations branch May 2, 2019 16:36
@m0ar
Copy link
Contributor

m0ar commented May 3, 2019

@ana0 For reference, this seems to do the trick for us (sans --owner-connection-string until we/graphile builds a postgraphile@4.4.0 docker image):

docker run --network="host" graphile/postgraphile --connection postgres://herp:derp@localhost:5432/vulcanize_public --schema maker --disable-default-mutations --no-ignore-rbac --watch --owner-connection-string postgres://bleep:bloop@localhost:5432/vulcanize_public

Should be equivalent to the bespoke setup, modulo the pg-simplify-inflector plugin which can be added with --append-plugins if it's installed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants