Fiber: ๐Ÿ”ฅ Official Graphql support

Created on 23 May 2020  ยท  11Comments  ยท  Source: gofiber/fiber

Is your feature request related to a problem?
Thanks for your all effort for making this ๐Ÿ”ฅ and โ™ฅ๏ธ framework. This is my goto framework when I work with go โœŒ๐Ÿป. And I also work extensively with graphql and It would be cool to have a official graphql plugin ๐Ÿ”ฅ.

Describe the solution you'd like
An official graphql plugin.

Additional context
Official Javascript implemetation: https://github.com/graphql/graphql-js
Fastify.js Implementation: https://github.com/mcollina/fastify-gql

Most helpful comment

@kockok are you able to fix it?

No, switched back to gin.

All 11 comments

Thanks for opening your first issue here! ๐ŸŽ‰ Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

Hi @numToStr , thanks for bringing up this issue!

We have however discussed this feature request in the past, however we do not think a GraphQL library should be official but rather something the end-user can import into their application.

I do recommend checking out https://github.com/arsmn/gqlgen and https://github.com/Just4Ease/fiber-gqlgen for importing GraphQL with Fiber.

Thank you for opening your first issue! ๐ŸŽ‰

Is there any documentation for using official graphql library (https://github.com/graphql-go/graphql) with fiber?

Hi @numToStr , thanks for bringing up this issue!

We have however discussed this feature request in the past, however we do not think a GraphQL library should be official but rather something the end-user can import into their application.

I do recommend checking out https://github.com/arsmn/gqlgen and https://github.com/Just4Ease/fiber-gqlgen for importing GraphQL with Fiber.

Thank you for opening your first issue! ๐ŸŽ‰

Can you create an official recipe as to integrate with gqlgen?
Especially for the context integration.

https://github.com/arsmn/gqlgen raises errors.

Screenshot 2020-07-17 at 5 35 32 PM

TnX

@kockok are you able to fix it?

@kockok are you able to fix it?

No, switched back to gin.

I have implemented gofiber with gqlgen and it is working for queries and mutations; however, subscriptions won't work because I need websockets. I tried to use gofiber websocket but it just not work. Has anyone successfully implemented gqlgen subscriptions with gofiber?

Could you show us what gqlgen subscriptions are?

Could you show us what gqlgen subscriptions are?

Got it working with arsmn's fork for fiber.
I have a new issue on: https://github.com/99designs/gqlgen/issues/1281

Hi!
How I solved the problem without subscriptions yet

package main
import (
    "net/http"
    "github.com/99designs/gqlgen/graphql/playground"
    "github.com/99designs/gqlgen/graphql/handler"
    "github.com/gofiber/fiber"
    "github.com/valyala/fasthttp/fasthttpadaptor"
)

func main() {
    app := fiber.New()

    app.Post("/query", func(ctx *fiber.Ctx) {
        h := handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: &Resolver{}}))
        fasthttpadaptor.NewFastHTTPHandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
            h.ServeHTTP(writer, request)
        })(ctx.Fasthttp)
    })
    app.Get("/", func(ctx *fiber.Ctx) {
        h := playground.Handler("GraphQL", "/query")
        fasthttpadaptor.NewFastHTTPHandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
            h.ServeHTTP(writer, request)
        })(ctx.Fasthttp)
    })
    app.Listen(3000)
}

To use @ftomza 's code on fiber/v2, instead of ctx.Fasthttp you have to use ctx.Context().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

faultable picture faultable  ยท  3Comments

bashery picture bashery  ยท  4Comments

Ivan-Feofanov picture Ivan-Feofanov  ยท  3Comments

koddr picture koddr  ยท  4Comments

mewben picture mewben  ยท  3Comments