Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fastify Example #10

Open
mthota15 opened this issue Apr 21, 2020 · 1 comment
Open

Fastify Example #10

mthota15 opened this issue Apr 21, 2020 · 1 comment

Comments

@mthota15
Copy link

Any example on how to run it with fastify? I was able to get postgraphile run with fastify. Now i am trying to include this plugin for file upload but not able to make it work.

Fastify with postgrapgile

const Fastify = require('fastify');
const helmet = require('fastify-helmet');
const cors = require('fastify-cors');
const Compress = require('fastify-compress');
const { postgraphile } = require('postgraphile');
const PgSimplifyInflectorPlugin = require('@graphile-contrib/pg-simplify-inflector');
const PostGraphileNestedMutations = require('postgraphile-plugin-nested-mutations');

const app = Fastify({
  logger: true,
});

// Register Plugins
app.register(cors);
app.register(helmet);
app.register(Compress, {
  global: true,
  threshold: 256, // bytes; below this size will not be compressed
});

// app.use(expressCompression({threshold: 0})); // working

// app.register(fastifyCompression, {threshold: 0}); // not working

app.use(
  postgraphile(
    'postgres://postgres:postgres@localhost:5432/demo_1?sslmode=disable',
    'app_public',
    {
      dynamicJson: true,
      appendPlugins: [PgSimplifyInflectorPlugin, PostGraphileNestedMutations],
      enhanceGraphiql: process.env.NODE_ENV !== 'production' ? true : false,
      graphileBuildOptions: {
        nestedMutationsSimpleFieldNames: true,
        nestedMutationsDeleteOthers: false,
      },
      disableQueryLog: process.env.NODE_ENV !== 'production' ? true : false,
      graphiql: process.env.NODE_ENV !== 'production' ? true : false,
      watchPg: process.env.NODE_ENV !== 'production',
    }
  )
);

app.listen(process.env.PORT || 3000, (err) => {
  if (err) {
    app.log.error(err);
    process.exit(1);
  }
});

i tried combing with this plugin: https://www.npmjs.com/package/fastify-gql-upload but no luck

@DarwinSenior
Copy link

I think this relies on implementation from graphql-upload, so if this resolves, then we can use it directly.

jaydenseric/graphql-upload#255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants