cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Deploying API using serverless, apollo, neo4j-driver, and neo4j-graphql-js

I'm doing serverless through AWS (API Gateway into a Lambda). Been working on it a few days and seem to have the grasp, but missing one big piece - actually getting it to update the schema and generate all the CRUD functionality. When I look at my neo4j database (hosted on an ec2 instance) in the browser, it is still showing the schema from when I was doing tutorials previously. Let me know if you all have any suggestions. Thanks!!

graphql.js

const { ApolloServer, gql } = require('apollo-server-lambda');
const { v1 } = require('neo4j-driver');
const { makeAugmentedSchema } = require('neo4j-graphql-js');

const driver = v1.driver(
  'bolt://ec2*********.amazonaws.com:7687',
  v1.auth.basic('neo4j','*****')
);

const typeDefs = `
  type User {
  id: ID!
  username: String
  email: String
  name: String
  firstName: String
  following: [User]
  followers: [User]
  reviews: [Review]
  futureEats: [Restaurant]
  foodRestrictions: [FoodRestriction]
}
type FoodRestriction {
  id: ID!
  name: String!
}

type Restaurant {
  id: ID!
  googlePlacesId: String!
  googleRating: Float!
  googlePriceLevel: Float!
  googleType: [String]
  website: String
  lat: Float!
  lng: Float!
  phone: String
  name: String!
  city: String!
  state: String!
  created_at: String!
  last_checked: String!
  reviews: [Review]
}

type Review {
  id: ID!
  rank: Int!
  recommendations: String
  photo: String
  restaurant: Restaurant!
  user: User!
}
`;

const schema = makeAugmentedSchema({
  typeDefs,
  config: {
    query: true, 
    mutation: true
  }
});

const server = new ApolloServer({
  schema: schema,
  context: { driver }
});

exports.graphqlHandler = server.createHandler();

serverless.yml

service: apollo-lambda
provider:
  name: aws
  runtime: nodejs6.10
functions:
  graphql:
    # this is formatted as <FILENAME>.<HANDLER>
    handler: graphql.graphqlHandler
    events:
    - http:
        path: graphql
        method: post
        cors: true
        integration: LAMBDA

1 REPLY 1

sakhsen
Node Link

Hi @nickhall122

Some of the following data type suggestions. Hope you might have updated by the time!
last_checked : DateTime
googlePlacesId: Point