Git Product home page Git Product logo

Comments (13)

Extarys avatar Extarys commented on June 20, 2024 3
import { SubscriptionServer } from 'subscriptions-transport-ws'
import { execute, subscribe } from 'graphql'
var httpSrv = fastify.listen(3002, err => {
	if (err) throw err;
	console.log('Server listenting on localhost:', fastify.server.address().port);
});
const graphSrv = new SubscriptionServer(
	{
		execute,
		subscribe,
		schemaGraph
	},
	{
		server: httpSrv,
		path: '/graphql'
	}
)

I have some schema issues, but that'S the code I have right now. Hope it works.

from fastify-graphql.

annibuliful avatar annibuliful commented on June 20, 2024 3

I fix it by changing httpServer to fastify.server it's not error but Subscription doesn't work. Why?

from fastify-graphql.

sirsavary avatar sirsavary commented on June 20, 2024 2

Apologies for not seeing this sooner! Thank you @Extarys for your example, I might document this in the README.

from fastify-graphql.

annibuliful avatar annibuliful commented on June 20, 2024 1

Thank you sir

from fastify-graphql.

annibuliful avatar annibuliful commented on June 20, 2024 1

Thank you sir

from fastify-graphql.

Extarys avatar Extarys commented on June 20, 2024

I had to change schemaGraph to schema: schemaGraph though (I forgot to change it in my first reply), hope you figured it out! 😄

from fastify-graphql.

Extarys avatar Extarys commented on June 20, 2024

No problem, my pleasure

from fastify-graphql.

annibuliful avatar annibuliful commented on June 20, 2024

screen shot 2561-05-12 at 00 03 46

screen shot 2561-05-12 at 00 04 29

it doesn't work . I don't know what are the problems

from fastify-graphql.

annibuliful avatar annibuliful commented on June 20, 2024

screen shot 2561-06-03 at 05 20 48

I'm not sure that [object object] is error or not ?

from fastify-graphql.

annibuliful avatar annibuliful commented on June 20, 2024

https://github.com/n3ologism/music-fastify/tree/backend/backend/src

This is my repository

from fastify-graphql.

nikitamarcius avatar nikitamarcius commented on June 20, 2024

@lagmanzaza tnx, its work for me fastify.server

import { execute, subscribe } from 'graphql'
import { SubscriptionServer } from 'subscriptions-transport-ws';

import { schema } from "./api/schema"

const fastify = require('fastify')({
	logger: false
})

// This `listen` method launches a web-server
fastify.listen(3000, (err, address) => {
	if (err) throw err
	console.log('\x1b[35m', `🚀 Server ready at http://localhost:3000/graphql`)
	console.log("\x1b[35m", `🚀 Subscription server ws://localhost:3000/graphql`)
})

new SubscriptionServer(
	{
		schema,
		execute,
		subscribe,
	},
	{
		server: fastify.server,
		path: '/graphql',
	},
);

from fastify-graphql.

annibuliful avatar annibuliful commented on June 20, 2024

@nikitamarcius Actually, You can use Apollo server instead

from fastify-graphql.

nikitamarcius avatar nikitamarcius commented on June 20, 2024

@lagmanzaza nope. Tried first, HTTP endpont works, but subscriptions no handshake error. Test with Koa and Fastify. Works only with HTTP native module

Better Graphql + Fastify + subscriptions.

from fastify-graphql.

Related Issues (11)

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.