I'm attempting to migrate a working, prisma-backed...
# orm-help
m
I'm attempting to migrate a working, prisma-backed, node EC2-based, graphql server to AWS Lambda. The function seems to be working up until the point at which the server makes a call to prisma. Then, in the server/lambda log, I get back: [Network error]: TypeError: Only absolute URLs are supported. Any thoughts?
m
@medelman are you using
Apex up
or
Serverless
? Are you following a tutorial?
m
I'm using CodeStar -- no tutorial. I can get the graphql server up and running (seemingly just fine). Only running into problems when the server makes a call to prisma-dev deployment.
m
what does your index file look like?
m
For the lambda function or for the server?
m
where's your prisma instance?
What's on your lambda function and what's on your server?!
index file for your lambda function
m
const graphqlServer = require('apollo-server-lambda'); const { db, schema } = require("./build/config/schema"); exports.graphqlHandler = graphqlServer.graphqlLambda((event, context) => { const headers = event.headers, functionName = context.functionName; return { schema: schema, context: { headers, functionName, event, context, db } } }); exports.graphiqlHandler = graphqlServer.graphiqlLambda({ endpointURL: '/graphql' });
it deploys the server to AWS Lambda
m
Not sure, but I will check it out. I read one about serverless, too, but I wanted to experiment with CodeStar
m
I know with graphql-yoga, they advised using
GraphQLServer
(not
graphqlLambda
)
that's probably as much help as I can give you
m
No worries. I appreciate the help. For the record, I tried using apollo-express-server as well and can get the exact same results. I'm gonna look into what you just noted. Will let you know.
m
how are you passing in your Prisma endpoint?
Here's my index.ts file:
Copy code
import { GraphQLServer } from 'graphql-yoga'
import { Prisma } from './generated/prisma'
import resolvers from './resolvers/resolvers'

const { PRISMA_ENDPOINT, PRISMA_SECRET, NODE_ENV, PORT } = process.env;
// the playground defaults to this port and not sure how to change it in dev mode
const port = PORT ? parseInt(PORT, 10) : 4000
const endpoint = NODE_ENV==="development" ? `${PRISMA_ENDPOINT}/dev` : `${PRISMA_ENDPOINT}/prod`;

const server = new GraphQLServer({
  typeDefs: './src/schema.graphql',
  resolvers,
  context: req => ({
    ...req,
    db: new Prisma({
      endpoint, // the endpoint of the Prisma DB service (value is set in .env)
      secret: PRISMA_SECRET, // taken from database/prisma.yml (value is set in .env)
      debug: NODE_ENV==="development" ? true : false, // log all GraphQL queries & mutations
    }),
  }),
})

server.start({ port }, () => console.log(`Server is running on <http://localhost:${PORT}`>))
@medelman
m
export const db = new Prisma({ typeDefs: td, endpoint: "https:///us1.prisma.sh/public-weeddeath-104/jimmy-butter/dev", secret: keys.PRISMA_SECRET, debug: true }); export const schema = makeExecutableSchema({ typeDefs, resolvers, directiveResolvers, logger: { log: e => Logger.error(e) } });
m
Are you suppose to have a triple
/
? "https:///us1.prisma.sh
m
ugh
I swear to god if that's it. I am going to kill someone.
and delete my account.
m
been there
m
fml that was it. 😭 Thanks a lot ESLINT.
But thank you, max, because I would have probably spent a few more hours pulling my hair out
m
🙂
👍 1
it was sorted in the end
all ends well
pay it foward
m
Haha yes. I am happy it's working. Will do.
fast parrot 1