Graphcool / graphcool-framework

Apache License 2.0
1.78k stars 130 forks source link

Relative imports not correctly resolved for dry run #447

Open marktani opened 6 years ago

marktani commented 6 years ago

Issue by marktani Thursday Dec 28, 2017 at 14:49 GMT Originally opened as https://github.com/graphcool/prisma/issues/1456


Current behavior

Relative imports, such as

const serviceAccount = require('./data.json')

is not correctly resolved when doing --dry-run. Error message:

:heavy_multiplication_x: Could not create serverless function for ‘myFunction’. Ensure that the code is valid

It works when normally deploying, however.

marktani commented 6 years ago

Comment by michaelspeed Thursday Dec 28, 2017 at 16:36 GMT


i found a solution - place firebase key in yml

firebaseAuthentication: type: resolver schema: handler: code: src: src/firebase/firebaseAuthentication.ts environment: firebasekey: '{ "type": "service_account", "project_id": "", "private_key_id": "", "private_key": "", "client_email": "", "client_id": "", "auth_uri": "", "token_uri": "", "auth_provider_x509_cert_url": "", "client_x509_cert_url": "" }'

and then from ts accessing it like this -

const serviceAccount = process.env['firebasekey'];

marktani commented 6 years ago

Comment by dohomi Friday Dec 29, 2017 at 08:04 GMT


This issue is quite frustrating if you share code between resolver functions. @michaelspeed your solution is good for simple things like keys but not if you want to require more complex code.