-
Notifications
You must be signed in to change notification settings - Fork 2k
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
apollo-server-hapi - multiple instances #931
Comments
We also have a use case for this and adding graphqlHapi.multiple = true
graphiqlHapi.multiple = true |
I have to agree, setting the default to true would make more sense. It's certainly the standard for the other servers, where we can add graphql endpoints with different routes and options and not be required to configure a global setting that enables this functionality. |
Running into this same issue with plugin: {
name: 'mockql',
register: graphqlHapi.register,
}, In |
@robmcguinness facing same issue here. Did you find any workaround to get two endpoints? I'm getting the following error: New route /.well-known/apollo/server-health conflicts with existing /.well-known/apollo/server-health |
I could workaround the Now the error is |
I extended ApolloServer and overrode const { ApolloServer } = require('apollo-server-hapi');
const { graphqlHapi } = require('apollo-server-hapi/dist/hapiApollo');
class MockApolloServer extends ApolloServer {
async applyMiddleware({ app, path, route, cors }) {
if (!path) path = '/mockql';
graphqlHapi.multiple = true;
await app.register({
plugin: graphqlHapi,
options: {
path,
graphqlOptions: this.createGraphQLServerOptions.bind(this),
route:
route !== undefined
? route
: {
cors: cors !== undefined ? cors : true,
},
},
});
this.graphqlPath = path;
}
} |
Awesome! thanks for the snippet! |
If you wanna live even more dangerously use: const { ApolloServer } = require('apollo-server-hapi')
const hapiApollo_1 = require('apollo-server-hapi/dist/hapiApollo')
hapiApollo_1.graphqlHapi.multiple = true
class MockApolloServer extends ApolloServer {
async applyMiddleware({ app, cors, path, disableHealthCheck, onHealthCheck }) {
return super.applyMiddleware({ app, cors, path, disableHealthCheck, onHealthCheck, hapiApollo_1 })
}
} |
I'm going to close this issue since it hasn't received any activity in quite some time, but I'm sympathetic to re-opening it if it's still a problem. It's also entirely possible that this is a documentation issue and if anyone feels that way, please do open a PR to the documentation (which lives within this repository in Lastly, we're introducing a |
First off, thanks for all the time and effort you guys (and the community) put into developing Apollo! It's really easy to get started and it works great!
I'm just hitting a few bumps with my specific implementation and i'm just wondering if I miss interpreted the documentation and i'm doing it all wrong or if this is something that hasn't been tried before and documented.
When i'm trying to achieve is having 3 different GraphQL endpoints each with their own set of schemas. Why? Because we want to show a different Model for user type A, B & Admin. I know we can just return different objects back from the business layer and just keep the fields empty for user types which are not allowed to see it. But the company i'm working for doesn't want to expose any information about the models to user types which aren't allowed to see it. (So they don't allow to document each field and show which user type has access it).
This is why i want to run multiple (3 in this case) instances of GraphQL each with their own set of schemas (and different models per endpoint). I haven't found anything about this in the docs and when i tried to register the plugin in hapi.js multiple times it gave an error that the plugin was already registered. I managed to 'fix' this by adding the multiple: true variable to the plugin. But i was wondering if this is 'safe' to do? Will i run into conflicts when running multiple instances of GraphQL on the same hapi.js server?
Would love to hear from you guys.
Kind regards,
Mike
The text was updated successfully, but these errors were encountered: