Migrating a firebase function that integrates Stripe into my site. Function takes some args like a client token, creates a stripe user using the stripe package and then saves the response to my database.
Trying to create a similar flow from 8base. I tried a trigger function first, since I want to create a new entry, but then I realized I cannot pass custom arguments to the trigger that don’t exist as fields in the table…
Now I am thinking a custom resolver would be better, I can whitelist args I need passed. But how would I actually create the entry after I have the response from stripe.customer.create? Do I write a mutation? How do I write a mutation on the custom function?
Additionally I am running into an error where the function does not find the stripe module. I have it in the package.json and the local invocation of the function works perfectly since I have it installed here. After deploying, it looks like the package doesn’t get installed.
Tinkering with webhooks, is there a good way to test locally?
- Also, I ran npm install just to create a package-lock.json, redeployed and yes, same error. Also on a new webhook function getting the deployed error “Cannot find module ‘graphql-tag’”
Seems like no packages are getting deployed properly. Did I miss something?
I am getting an notice during the deploy during the compiling step:
Node modules have reached max size. Cannot use fast deploy.
Could this be the culprit?
@tehfailsafe
There is invoke-local
command in the cli which allows to test custom functions.
For example:
8base invoke-local webhookName --data-json '{"body": "{\"foo\":\"bar\"}"}'
Or you can store your data in a json file.
8base invoke-local webhookName --data-path path/to/my/data.json
I think it could. What is size of your node_modules
directory?
Also, delete package-lock.json. 8base-cli works with yarn.lock too.
@vorobeez 415 MB (713 MB on disk). This is a Gatsby app with very little additional packages, so I can only assume this will grow with things like moment.js or eCharts, moderately bigger packages I will need to add.
It looks like 8base deploy is taking the entire project up along with what the functions need. I assumed there would be some tree-shaking and it wouldn’t push modules that aren’t being used… I think the solution might be as simple as moving my functions outside of my project site root and creating it’s own package.json for just functions.
Was that the intended configuration all along? Should that be updated from the docs to not mix front end and 8base init setups? It seems obvious now but it wasn’t intuitive. I wanted to be able to share queries between front end and custom functions, but I suppose it’s not worth the hassle if this is a problem.
@tehfailsafe thanks for reporting. @sebastian.scholl we defenitely need to add this to documentation.
1 Like