Graphback: Expose MAX_RETRIES as an environment variable to templates

Created on 11 Aug 2020  路  9Comments  路  Source: aerogear/graphback

Context: https://github.com/aerogear/graphback/pull/1833#discussion_r467787854

The MAX_RETRIES value for conflict resolution is hard-coded into Graphback. It would be very useful if this was configurable from the templates through an environment variable.

If the user does not set this value, it should fall back on a default (the current value).

https://github.com/aerogear/graphback/blob/8763612f240a59cd15c011333c7d6fab530050ec/packages/graphback-datasync/src/providers/DataSyncConflictProvider.ts#L6

good first issue Hacktoberfest datasync up for grabs

All 9 comments

/cc @craicoverflow, @wtrocki
Automatically generated comment to notify maintainers

Could you add more to the description of this issue? This is a nice first issue for someone but requires reading of old PRs for context.

I've updated the issue description.

Hey I'd like to work on this! How would I have access to the value the user has entered for MAX_RETRIES?

Thanks! By reading it from an environment variable.

Thanks for responding! I'm not sure if I get what you mean. I don't see a .env file in the providers folder so how will I use something like process.env._userInput in DataSyncConflictProvider.ts.

You are welcome!

The template is where the .env file exists - it is already there athttps://github.com/aerogear/graphback/blob/master/templates/ts-apollo-mongodb-datasync-backend/.env

This is where the user would configure the value

There does not need to be a .env file in the providers folder, you need to export it from here.

+1 on this variable to be configurable via environment variables.

As for the naming we can go with CONFLICT_RESOLUTION_MAX_RETRIES, but we are open to suggestions /cc @ssd71 @wtrocki

We we'll need to do here is read the variable from process.env, if it's set use that value, otherwise default to 3.

As for the .env file, there is no need for it in the DataSyncConflictProvider.ts or the datasync package but we'll need to add this inside our datasync template, in this file https://github.com/aerogear/graphback/blob/8763612f240a59cd15c011333c7d6fab530050ec/templates/ts-apollo-mongodb-datasync-backend/.env to be precise.

It will be also cool to have it documented even a bit in https://github.com/aerogear/graphback/blob/e2b505010e3bc0679f64110446c3e07e316c326b/docs/datasync/conflict-resolution-intro.md

Thanks @craicoverflow @RinkiyaKeDad

Closed by #2160 Thanks @RinkiyaKeDad for the great work.

Was this page helpful?
0 / 5 - 0 ratings