hi guys, some of you have had issues importing the...
# prisma-whats-new
hi guys, some of you have had issues importing the aws-sdk to a custom resolver?
import aws from 'aws-sdk'
I got it is undefined and I installed it already. Thanks in advance
hey @ed I am not 100% sure, but
may not have default expose… 🤞 (very unlikely). You can still, though, try importing a concrete module of
, S3, for example.
Copy code
import { S3 } from 'aws-sdk'
thanks @matic, So, how can we set our custom credentials?
credentials? Like
etc…? afaik each module should support custom configuration. S3 for example, handles it like this:
Copy code
const s3client = new S3({
  accessKeyId: process.env.S3_ACCESS_KEY_ID,
  secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
  params: {
    Bucket: process.env.S3_BUCKET,
ok, no, I think that the problem should be somewhere else -
does expose a global module https://github.com/aws/aws-sdk-js
@ed can you share other parts of your code?
@matic importing only the s3 module and putting the credentials inside worked, however importing the whole module returns undefined, I dont think thats an aws-sdk issue due to I did the same code but using the global module in frontend and worked great, maybe graphcool is blocking that import. Thank you so much for the help fast parrot
@ed no problem, I am happy to help! Could you still share the code which caused the problem, so we can try to debug it and find if there’s an underlying problem? 🙂
Copy code
import { fromEvent, FunctionEvent } from 'graphcool-lib'
import { GraphQLClient } from 'graphql-request'
import AWS from 'aws-sdk'
import { v4 } from 'uuid'

interface EventData {
  fileType: string
export default async (event: FunctionEvent<EventData>) => {
  try {
        accessKeyId: __ACCESS_KEY__,
        secretAccessKey: __SECRET_KEY__,
        region: __REGION__
    const graphcool = fromEvent(event)
    const api = graphcool.api('simple/v1')
    const { fileType } = event.data
    const s3 = new AWS.S3()
    const key = v4()
    const params = {
      Bucket: `cosporter`,
      Key: key,
      Expires: 60,
      ContentType: fileType && fileType
    const url = await s3.getSignedUrl('putObject', params)
    return { data: {url, key} }
  } catch (e) {
    return { error: `An unexpected error occured. ${e}` }
💚 1
So, that code doesnt work as
is undefined, even if I do console.log(AWS) i got undefined
@ed in the graphcool-framework functions you need to do
import * as aws from 'aws-sdk'
👍 1
see the example above
thanks @max that works too