Giter Site home page Giter Site logo

Comments (4)

tmr08c avatar tmr08c commented on June 6, 2024

Using this as a sample, I was able to deploy the api part of the app.

I created a now.json file in the project's root:

{
  "version": 2,
  "builds": [
    { "src": "./api/src/index.js", "use": "@now/node-server" }
  ],
  "routes": [
    { "src": "/.*", "dest": "/api/src/index.js" }
  ]
}

This is using @now/node-server which Zeit doesn't seem to really want you to use. I think changes could be made to use @now/node(my hunch is api/src/index.js would need to do be set up like an Apollo Lamda function).

If you want to add environmental variables to talk to you can do something like:

{
  "version": 2,
  "builds": [
    { "src": "./api/src/index.js", "use": "@now/node-server" }
  ],
  "routes": [
    { "src": "/.*", "dest": "/api/src/index.js" }
  ],
  "env": {
    "NEO4J_URI": "bolt://localhost: 7687",
    "NEO4J_USER": "neo4j",
    "NEO4J_PASSWORD": "letmein",
    "GRAPHQL_LISTEN_PORT": "4000"
  }
}

To get the playground to work when I deployed I also had to update the creation of the ApolloServer:

// api/src/index.js
const server = new ApolloServer({
  context: { driver },
  schema: schema,
  introspection: true,
  playground: true,
});

With these changes, I was able to deploy with now and connect to a playground that was connected to my sandbox DB.

I was unable to get the routes in now.json to do something like have the server run at /api. This may have something to do with how @now/node-server works, but I'm not sure.

Because of the issue with nesting deploying the UI part gets a little weird, so I tried making a separate now.json file in the ui directory following this guide. Unfortunately, I ran up against this open issue. It looks like a fix may be incoming though.

from grand-stack-starter.

cloudwheels avatar cloudwheels commented on June 6, 2024

Hi @tmr08c . Is your build of api still running?

I've got as far as building 'successfully' (ie without build errors) (I didn't add a route, but the explorer serves from src/index.js).

The ENV variables only seem to be picked up from the now.json file (which is fine, there is some older documentation from Zeit about passing these and secrets with an -e parameter at build time or apply them after a restart which I haven't tested yet).

But the explorer is not finding the Apollo server. I've tried various configs for initialising and connecting explorer to the api (localhost, 0.0.0.0, 127.0.0.1, the zeit app url). At one point logs suggested the server was exposing port 4000, but before I added the env variables it appeared to be starting on a high port (35***) and now I'm a bit confused about exactly what is happening in this build process, so any pointers welcome.

This is a great project ./ stack and super easy just to fire up with Gitpod and a neo4j sandbox, build and enjoy, all for that lovely 'free' word.

It's a bit of a let down having to bash the brain with config for a third party tool and a world of difference if it was the one click process it could/should/will I'm sure be when I work it out!

Alternatively has anyone built a heroku? (for the server - I would be very happy to keep the front-end separate and sure there are plenty of options for this)

Even more alternatively, [in the rest of my spare time :)] I was thinking to look at a serverless implementation and spin up the server as a firebase cloud function: there are various examples of doing this with express out there, but if anyone's there already with this stack...??

[edit]
Like this maybe: https://github.com/Rusfighter/firegraph
see blog article: https://itnext.io/serverless-graphql-with-free-cdn-in-memory-caching-766c1e29376a

from grand-stack-starter.

MattGyverLee avatar MattGyverLee commented on June 6, 2024

Hi folks, this may be fixed based on #58 .

from grand-stack-starter.

ed42311 avatar ed42311 commented on June 6, 2024

Think this is good to go, but I'll double check next week.

from grand-stack-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.