Coder Social home page Coder Social logo

Comments (10)

mcollina avatar mcollina commented on July 30, 2024 1

You should use the plugin interface, not the middleware one. There is plenty of docs in the repo, so there should be all that you need.
All the requirements you are listing can be implemented using the normal fastify API.

Have a look and let us know if you need any specifics details.

from fastify.

 avatar commented on July 30, 2024 1

I'd seen this start over at Apollo (apollographql/apollo-server#402, apollographql/apollo-server#421). I assume they'll include it eventually since they have an option for micro.

But I wanted to port a project from work that runs with Apollo and express over to fastify. I like the possibilities with hooks for some use cases better than clunky express (authn, authz, graphql context, etc.). mcollina mentioned it as a plugin, so I took a stab at my first OSS project and made fastify-apollo. I hope an Apollo server lines up with fastify's ecosystem.

from fastify.

delvedor avatar delvedor commented on July 30, 2024

Hi! Yes it's the expected behavior as you can see here.
The parsing is done after the routing. If you want you can use the preHandler hook, that gives you everything you need :)

from fastify.

mcollina avatar mcollina commented on July 30, 2024

I think you should not use middlewares for integrating with Apollo, but rather develop a full blown plugin for Fastify.

from fastify.

phra avatar phra commented on July 30, 2024

i can investigate also that way, for now i've just followed the structure of other integrations.
can you please give me additional infos on the solution you are thinking about?

as i can see the requirements to make apollo works are:

  • ability to intercept only certain paths (/graphql and /graphiql)
  • ability to access to the req.body for POST or req.query for GET
  • ability to set custom headers on the Reply
  • ability to write raw data in the Reply stream
  • ability to close the Reply stream

you can also find the actual example usage with the middleware solution here

thanks.

EDIT: that's the original issue that i opened 20 days ago, if you want to add a comment there for some reason.

from fastify.

phra avatar phra commented on July 30, 2024

ok, i'll let you know guys. thanks for the suggestion.

from fastify.

delvedor avatar delvedor commented on July 30, 2024

Closing this, feel free to reopen if you have some issues :)

from fastify.

mcollina avatar mcollina commented on July 30, 2024

@coopnd this is amazing work! Would you like to send us a PR to the README https://github.com/fastify/fastify#ecosystem

Let us know if you get any bugs in fastify, open them or send PRs.

from fastify.

delvedor avatar delvedor commented on July 30, 2024

Awesome, thanks! :)

from fastify.

phra avatar phra commented on July 30, 2024

@coopnd good job! 🚀

from fastify.

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.