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

Can I use with Graphql subscription ? #9

Closed
annibuliful opened this issue Apr 12, 2018 · 13 comments
Closed

Can I use with Graphql subscription ? #9

annibuliful opened this issue Apr 12, 2018 · 13 comments

Comments

@annibuliful
Copy link

No description provided.

@Extarys
Copy link

Extarys commented May 9, 2018

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.

@annibuliful
Copy link
Author

Thank you sir

@Extarys
Copy link

Extarys commented May 9, 2018

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

@annibuliful
Copy link
Author

Thank you sir

@sirsavary
Copy link
Owner

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

@Extarys
Copy link

Extarys commented May 9, 2018

No problem, my pleasure

@annibuliful
Copy link
Author

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

@annibuliful annibuliful reopened this May 11, 2018
@annibuliful
Copy link
Author

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

@annibuliful
Copy link
Author

screen shot 2561-06-03 at 05 20 48

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

@annibuliful
Copy link
Author

@odlainepre
Copy link

odlainepre commented Apr 18, 2020

@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',
	},
);

@annibuliful
Copy link
Author

@nikitamarcius Actually, You can use Apollo server instead

@odlainepre
Copy link

odlainepre commented Apr 20, 2020

@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.

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

4 participants