# Slash Lambda with Packages

**URL:** <https://discuss.dgraph.io/t/slash-lambda-with-packages/12321>\
**Category:** Dgraph Cloud\
**Tags:** kind:question, lambda\
**Created:** [January 15, 2021, 7:06pm UTC](https://discuss.dgraph.io/t/slash-lambda-with-packages/12321 "2021-01-15T19:06:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [January 15, 2021, 7:06pm UTC](https://discuss.dgraph.io/t/slash-lambda-with-packages/12321/1 "2021-01-15T19:06:04Z")

</div>

[Dgraph GraphQL Lambda Overview](https://dgraph.io/docs/graphql/lambda/overview/) docs state:

> Webpack is required to use the sample `rank()` function.

This seems to jive with [dgraph/dgraph-lambda](https://github.com/dgraph-io/dgraph-lambda#adding-libraries) readme on Github

> If you would like to add libraries, then use webpack --target=webworker to compile your script. We’ll fill out these instructions later.

I believe “these instructions” refer to compiling the lambda script with webpack. I believe Slash does this compiling for us already.

So… what packages can we import? Anything on npm? A list of approved packages? I would probably be able to answer this myself if I knew more about webpack and didn’t rely on React magic.

---

<div class="post-metadata">

**Author:** ![pbassham](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pbassham/32/3672_2.png) [@pbassham](https://discuss.dgraph.io/u/pbassham)\
**Post date:** [January 15, 2021, 7:15pm UTC](https://discuss.dgraph.io/t/slash-lambda-with-packages/12321/2 "2021-01-15T19:15:08Z")

</div>

For instance, currently I am wanting to make some queries to the Google Maps API, which requires Axios for the requests…

> **[GitHub - googlemaps/google-maps-services-js: Node.js client library for...](https://github.com/googlemaps/google-maps-services-js)**
>
> Node.js client library for Google Maps API Web Services - GitHub - googlemaps/google-maps-services-js: Node.js client library for Google Maps API Web Services

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [February 8, 2021, 2:44am UTC](https://discuss.dgraph.io/t/slash-lambda-with-packages/12321/3 "2021-02-08T02:44:06Z")

</div>

This is something I ran into today as well. I tried importing `'markdown-it'` in my lambda script on Slash and it turns out to be an error

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [February 8, 2021, 2:49am UTC](https://discuss.dgraph.io/t/slash-lambda-with-packages/12321/4 "2021-02-08T02:49:48Z")

</div>

Yeah, you have to compile it if you want to import any packages. There is no current examples how to do this still though.

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [February 8, 2021, 2:52am UTC](https://discuss.dgraph.io/t/slash-lambda-with-packages/12321/5 "2021-02-08T02:52:59Z")

</div>

Ugh. Now I am gonna see if I can get away without installing any nodejs on my pristine-untouched-by-js computer.

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [February 8, 2021, 2:59am UTC](https://discuss.dgraph.io/t/slash-lambda-with-packages/12321/6 "2021-02-08T02:59:31Z")

</div>

@amaster507 You did the auth thing with a `@custom` on netlify… is netlify free or do I have to pay?

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [February 8, 2021, 5:38am UTC](https://discuss.dgraph.io/t/slash-lambda-with-packages/12321/7 "2021-02-08T05:38:49Z")

</div>

It has a free tier. Can’t remember how many calls per month you get but it is a fair amount. AWS also has a free tier for lambdas I believe.

---

<div class="post-metadata">

**Author:** ![jackl](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jackl/32/10089_2.png) [@jackl](https://discuss.dgraph.io/u/jackl)\
**Post date:** [September 20, 2021, 9:31pm UTC](https://discuss.dgraph.io/t/slash-lambda-with-packages/12321/8 "2021-09-20T21:31:05Z")

</div>

I noticed @amaster507 never really got an answer to his question. I have the same question. Is there more information somewhere that I’ve just missed?

Also, the dgraph docs have, instead of “[filling out] these instructions later”, _simply removed that line where they say they’ll fill out the instructions later_. 😄

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [September 20, 2021, 10:00pm UTC](https://discuss.dgraph.io/t/slash-lambda-with-packages/12321/9 "2021-09-20T22:00:58Z")

</div>

You have to compile your scripts into an output that will also include the packages you want to include and then copy and paste all of that output into the lambda script. It is not pretty or friendly. I just found an alternative lambda provider when my scripts need packages to be compiled but that loses a little bit of the power and purpose of Dgraph having the lambda close to the db.

Another reason why the “almighty” lambda is not always the best solution. It would be better if it was to work more closely like Auth0 uses custom scripts.

---

<div class="post-metadata">

**Author:** ![gja](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/gja/32/2654_2.png) [@gja](https://discuss.dgraph.io/u/gja)\
**Post date:** [September 23, 2021, 2:28am UTC](https://discuss.dgraph.io/t/slash-lambda-with-packages/12321/10 "2021-09-23T02:28:12Z")

</div>

Most libraries with work with lambda if they are

- written in pure JS (no c++ extensions )
- do not try to access file system or environment.

I think the “fill this out later” went onto the lambda docs site. But basically: use Webpack to make a single file.
