Coder Social home page Coder Social logo

Comments (6)

benjie avatar benjie commented on June 11, 2024

The CLI takes the flags and converts them into library-mode equivalents, e.g. here's where it takes the connection CLI flag and adds it to the configuration for library mode:

const newPgServices = [
makePgService({
connectionString,
schemas,
superuserConnectionString,
...(rawSubscriptions ? { pubsub: true } : null),
}),
];
preset.pgServices = newPgServices;

Please can you show a reproduction of your issue?

from crystal.

sidux avatar sidux commented on June 11, 2024

Sorry, actually it's due the -c option not really related to the library mode.

file : .env

DATABASE_URL=postgres://dev:dev@locahost:5430/flashdb

file : graphile.config.js

import { PostGraphileAmberPreset } from "postgraphile/presets/amber";
import { PgSimplifyInflectionPreset } from "@graphile/simplify-inflection";
import { makePgService } from "postgraphile/adaptors/pg";
import dotenv from "dotenv";

dotenv.config({ path: ".env" });

const preset = {
  extends: [PostGraphileAmberPreset, PgSimplifyInflectionPreset],
  schema: {
    pgJwtSecret: process.env.JWT_SECRET,
  },
  gather: {
    pgJwtTypes: "jwt_token",
  },
  pgServices: [
    makePgService({
      connectionString: process.env.DATABASE_URL,
      pubsub: true,
    }),
  ],
  grafserv: { watch: true },
};

export default preset;

when running postgraphile it doesn't work (error : postgres says: Error: getaddrinfo ENOTFOUND locahost)
when running postgraphile -c 'postgres://dev:dev@localhost:5430/flashdb' it works fine

If edit .env file with :

DATABASE_URL=postgres://dev:[email protected]:5430/flashdb

both work fine

from crystal.

benjie avatar benjie commented on June 11, 2024

You’ve misspelt localhost as locahost.

from crystal.

sidux avatar sidux commented on June 11, 2024

Oh yeah sorry, It was a mistake while trying to reproduce, but still after fixing it DATABASE_URL=postgres://dev:dev@localhost:5430/flashdb

bun postgraphile command works
but
bun server.ts doesn't work

both work well with 127.0.0.1

here is my server.ts

import Fastify from "fastify";
import { grafserv } from "grafserv/fastify/v4";
import preset from "./graphile.config.js";
import { postgraphile } from "postgraphile";

const pgl = postgraphile(preset);
const server = pgl.createServ(grafserv);
const app = Fastify({ logger: true });

server.addTo(app).catch((e) => {
  console.error(e);
  process.exit(1);
});

app.listen({ port: preset.grafserv?.port ?? 5678 }, (err, address) => {
  if (err) throw err;
  console.log(`Server is now listening on ${address}`);
});

from crystal.

sidux avatar sidux commented on June 11, 2024

Btw I understood the real cause, it works well with localhost using tsx server.ts but doesn't with bun, for some reason I had to use 127.0.0.1 instead for bun to work.

from crystal.

benjie avatar benjie commented on June 11, 2024

Please in future mention you’re using bun up front, this probably goes for filing an issue against any Node.js module that you’re having issues with under bun or any alternative runtime. Glad you figured it out.

from crystal.

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.