How to update schema without restarting service
up vote
0
down vote
favorite
My program uses apollo-server-koa as graphql service and I want to update schema dynamically. For example:
- When user uploads data to server, the schema also need to be updated but not restarting service.
I read schema transform and schema stitching but these don't meet my requirement.
Anyone can give me an advice.
Thank you so much!
graphql apollo-server
add a comment |
up vote
0
down vote
favorite
My program uses apollo-server-koa as graphql service and I want to update schema dynamically. For example:
- When user uploads data to server, the schema also need to be updated but not restarting service.
I read schema transform and schema stitching but these don't meet my requirement.
Anyone can give me an advice.
Thank you so much!
graphql apollo-server
In particular case, I want to update both a typedef and a resolver
– Huongnt
Nov 8 at 17:06
Apollo doesn't support updating the schema dynamically. If you want to do that, you'd need to set up your own middleware, recreate the schema each request and callgraphql
'sexecute
function yourself.
– Daniel Rearden
Nov 8 at 17:13
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My program uses apollo-server-koa as graphql service and I want to update schema dynamically. For example:
- When user uploads data to server, the schema also need to be updated but not restarting service.
I read schema transform and schema stitching but these don't meet my requirement.
Anyone can give me an advice.
Thank you so much!
graphql apollo-server
My program uses apollo-server-koa as graphql service and I want to update schema dynamically. For example:
- When user uploads data to server, the schema also need to be updated but not restarting service.
I read schema transform and schema stitching but these don't meet my requirement.
Anyone can give me an advice.
Thank you so much!
graphql apollo-server
graphql apollo-server
asked Nov 8 at 16:56
Huongnt
113
113
In particular case, I want to update both a typedef and a resolver
– Huongnt
Nov 8 at 17:06
Apollo doesn't support updating the schema dynamically. If you want to do that, you'd need to set up your own middleware, recreate the schema each request and callgraphql
'sexecute
function yourself.
– Daniel Rearden
Nov 8 at 17:13
add a comment |
In particular case, I want to update both a typedef and a resolver
– Huongnt
Nov 8 at 17:06
Apollo doesn't support updating the schema dynamically. If you want to do that, you'd need to set up your own middleware, recreate the schema each request and callgraphql
'sexecute
function yourself.
– Daniel Rearden
Nov 8 at 17:13
In particular case, I want to update both a typedef and a resolver
– Huongnt
Nov 8 at 17:06
In particular case, I want to update both a typedef and a resolver
– Huongnt
Nov 8 at 17:06
Apollo doesn't support updating the schema dynamically. If you want to do that, you'd need to set up your own middleware, recreate the schema each request and call
graphql
's execute
function yourself.– Daniel Rearden
Nov 8 at 17:13
Apollo doesn't support updating the schema dynamically. If you want to do that, you'd need to set up your own middleware, recreate the schema each request and call
graphql
's execute
function yourself.– Daniel Rearden
Nov 8 at 17:13
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
I do this with apollo-server-express@1.3.2. I haven't converted over to 2 yet, and I'm not doing koa, but it'd be roughly the same, I assume. If not, hopefully it at least helps.
const { graphqlExpress } = require('apollo-server-express')
let schema = loadRemoteSchemas() // this loads it on start-up
app.use(async (req, res) => {
return {
schema: await schema,
}
}
app.use('refresh', async (req, res) => {
// some middleware that does stuff and changes the `schema` pointer
})
I know this but my project use apollo server 2
– Huongnt
2 hours ago
But in your solution, i found it performance is not good because server have to rebuild schema for each request
– Huongnt
2 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I do this with apollo-server-express@1.3.2. I haven't converted over to 2 yet, and I'm not doing koa, but it'd be roughly the same, I assume. If not, hopefully it at least helps.
const { graphqlExpress } = require('apollo-server-express')
let schema = loadRemoteSchemas() // this loads it on start-up
app.use(async (req, res) => {
return {
schema: await schema,
}
}
app.use('refresh', async (req, res) => {
// some middleware that does stuff and changes the `schema` pointer
})
I know this but my project use apollo server 2
– Huongnt
2 hours ago
But in your solution, i found it performance is not good because server have to rebuild schema for each request
– Huongnt
2 hours ago
add a comment |
up vote
0
down vote
I do this with apollo-server-express@1.3.2. I haven't converted over to 2 yet, and I'm not doing koa, but it'd be roughly the same, I assume. If not, hopefully it at least helps.
const { graphqlExpress } = require('apollo-server-express')
let schema = loadRemoteSchemas() // this loads it on start-up
app.use(async (req, res) => {
return {
schema: await schema,
}
}
app.use('refresh', async (req, res) => {
// some middleware that does stuff and changes the `schema` pointer
})
I know this but my project use apollo server 2
– Huongnt
2 hours ago
But in your solution, i found it performance is not good because server have to rebuild schema for each request
– Huongnt
2 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
I do this with apollo-server-express@1.3.2. I haven't converted over to 2 yet, and I'm not doing koa, but it'd be roughly the same, I assume. If not, hopefully it at least helps.
const { graphqlExpress } = require('apollo-server-express')
let schema = loadRemoteSchemas() // this loads it on start-up
app.use(async (req, res) => {
return {
schema: await schema,
}
}
app.use('refresh', async (req, res) => {
// some middleware that does stuff and changes the `schema` pointer
})
I do this with apollo-server-express@1.3.2. I haven't converted over to 2 yet, and I'm not doing koa, but it'd be roughly the same, I assume. If not, hopefully it at least helps.
const { graphqlExpress } = require('apollo-server-express')
let schema = loadRemoteSchemas() // this loads it on start-up
app.use(async (req, res) => {
return {
schema: await schema,
}
}
app.use('refresh', async (req, res) => {
// some middleware that does stuff and changes the `schema` pointer
})
answered yesterday
Dan Crews
1,4891019
1,4891019
I know this but my project use apollo server 2
– Huongnt
2 hours ago
But in your solution, i found it performance is not good because server have to rebuild schema for each request
– Huongnt
2 hours ago
add a comment |
I know this but my project use apollo server 2
– Huongnt
2 hours ago
But in your solution, i found it performance is not good because server have to rebuild schema for each request
– Huongnt
2 hours ago
I know this but my project use apollo server 2
– Huongnt
2 hours ago
I know this but my project use apollo server 2
– Huongnt
2 hours ago
But in your solution, i found it performance is not good because server have to rebuild schema for each request
– Huongnt
2 hours ago
But in your solution, i found it performance is not good because server have to rebuild schema for each request
– Huongnt
2 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53212575%2fhow-to-update-schema-without-restarting-service%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
In particular case, I want to update both a typedef and a resolver
– Huongnt
Nov 8 at 17:06
Apollo doesn't support updating the schema dynamically. If you want to do that, you'd need to set up your own middleware, recreate the schema each request and call
graphql
'sexecute
function yourself.– Daniel Rearden
Nov 8 at 17:13