tailcall icon indicating copy to clipboard operation
tailcall copied to clipboard

Read environmental variables from `.env` files

Open rajdip-b opened this issue 1 year ago • 8 comments

Is your feature request related to a problem? Please describe. Most of the time we have a .env file in our directory that contains all the secret. Right now, there is no way to directly use this file to resolve the env keys in the mustache statement.

Describe the solution you'd like It would be nice to automatically detect and parse all environment variables in our mustache templates, rather than having to explicitely specifying them in our runtime environment.

Usage: If we have a .env file with the following content in it,

API_ENDPOINT=myapi.com

Then, this block should work by default.

type Query {
  users: [User]! @http(baseUrl: "{{env.API_ENDPOINT}}", path: "/users")
}

rajdip-b avatar Dec 31 '23 13:12 rajdip-b

Agree. I suggested it when working on #790, but it was outside that issue's scope.

wesleymatosdev avatar Dec 31 '23 15:12 wesleymatosdev

/bounty 120$

tusharmath avatar Jan 01 '24 10:01 tusharmath

💎 $120 bounty created by tailcallhq 🙋 If you start working on this, comment /attempt #859 along with your implementation plan 👉 To claim this bounty, submit a pull request that includes the text /claim #859 somewhere in its body

📝 Before proceeding, please make sure you can receive payouts in your country. 💵 Payment arrives in your account 2-5 days after the bounty is rewarded. 💯 You keep 100% of the bounty award. 👍 If you go above and beyond by cleaning up or enhancing aspects beyond the scope of the PR, a tip may be awarded as a token of appreciation. 🙏 Thank you for contributing to tailcallhq/tailcall!. 🙋‍♂️ Join our discord channel if you need help.

👉 Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🔴 @ksh0205 Jan 1, 2024, 11:02:30 AM WIP

algora-pbc[bot] avatar Jan 01 '24 10:01 algora-pbc[bot]

/attempt #859

ksh0205 avatar Jan 01 '24 11:01 ksh0205

@ksh0205: The Tailcall Inc. team prefers to assign a single contributor to the issue rather than let anyone attempt it right away. We recommend waiting for a confirmation from a member before getting started.

algora-pbc[bot] avatar Jan 01 '24 11:01 algora-pbc[bot]

Hi @tusharmath, Can I give it a shot? Can you assign the issue to me.

ksh0205 avatar Jan 01 '24 11:01 ksh0205

I'd like to work on this one as I implemented part of the env thing already

wesleymatosdev avatar Jan 01 '24 13:01 wesleymatosdev

I started working on it, and I'll use env-file-reader to read the env.

one question: Do we want a new operator or a new field on an existing operator?

IMO, we could add an env_file, env_path, or something like that on the @server operator or create an @env operator.

e.g.:

# new field on server operator
@server(env_path: ".env.something")

# OR

# new env operator
@env(path: ".env.something")

what do you think @tusharmath?

wesleymatosdev avatar Jan 02 '24 20:01 wesleymatosdev

As discussed on Discord, we'll use @link for that, so we're blocked until #760 be resolved.

wesleymatosdev avatar Jan 08 '24 02:01 wesleymatosdev

is this closed? I still this issue as open in algora

Bhavyajain21 avatar Mar 02 '24 08:03 Bhavyajain21

It's really open @Bhavyajain21. I'm assigned to this one but feel free to give it a shot if you want to

wesleymatosdev avatar Mar 02 '24 10:03 wesleymatosdev

fixed in https://github.com/tailcallhq/tailcall/pull/1523

tusharmath avatar Mar 21 '24 18:03 tusharmath