Apollo-server: Defer usage

Created on 30 Nov 2018  路  4Comments  路  Source: apollographql/apollo-server

On my Apollo Server I am running:

"apollo-server": "^2.2.5",
"express": "^4.16.4",
"graphql": "^14.0.2",
"graphql-tools": "^4.0.3",

But I am unable to try out the defer directive, as my server is returning: Unknown directive "defer".

I am unsure how to enable this feature. I have read all information I could find on defer, but no matter what I do I can not enable it. On my client I am also running latest version of React Apollo.

How do I enable defer? :-)

Most helpful comment

can you please give a hint on the docs that @defer is currently not working and a upcoming feature?

All 4 comments

I got the same issue using apollo-server and apollo-server-express.

package.json:

"apollo-server": "^2.4.0-alpha.0",
"apollo-server-express": "^2.4.0-alpha.0"

Within the defer support doc it says that I have to explicit enable the support when using apollo-server-express but without actually explaining how to add my custom handler.

I managed to find some updates on defer from the #defer channel on Apollo Slack Community:

@hwillson wrote on October 18th 2018

Regarding the status of the @defer PR鈥檚; we鈥檙e in the middle of some pretty extensive Apollo Server changes / refactoring behind the scenes, all of which will impact how @defer support is handled on the server. Once those changes are done, we鈥檙e going to circle back and get all of the @defer PR鈥檚 updated, and pushed out. This likely won鈥檛 happen until after Graphql Summit though, so possibly mid to late November.

And on December 18th 2018:

@defer support touches on 4 different projects (Apollo Client, React Apollo, Apollo Link, and Apollo Server). Things are pretty much ready to go with the first 3 (other than the @defer PR鈥檚 being out of synch, but those are easy to fix). The issue is the pending changes required for Apollo Server, to make everything work. The POC changes for Apollo Server work, but we鈥檙e concerned about their performance (not a fault of the current Apollo Server @defer PR; it鈥檚 a fault of the current Apollo Server architecture). We鈥檙e planning on making several changes to Apollo Server to not only accommodate @defer support in a safer and more performant way, but these changes will also open the door to other similar changes, like @stream support (which is also on our list). We鈥檙e not quite ready to start working on these changes in Apollo Server, but this task is being tracked and is in our backlog (and I鈥檝e flagged it as being high priority).

I can really only speak for @defer support in Apollo Client, React Apollo and Apollo Link (since I鈥檒l be helping get that work in place). The @defer functionality in the outstanding Apollo client side PR鈥檚 is highly dependent on the Apollo Server @defer support approach. So for now those PR鈥檚 are at a bit of a stand still, until the server side approach is nailed down. @martijnwalraven and @abernix can help answer questions about the plans for Apollo Server @defer support.

@martijnwalraven chipped in with

Unfortunately, we haven鈥檛 been able to get back to this yet, so we don鈥檛 have anything to share. what needs to happen is basically an overhaul of the apollo server architecture to support pluggable transports. right now, only the http transport runs through the request pipeline, meaning using websockets doesn鈥檛 support most of the apollo server features. we need to change this, and also define a more flexible response api in the request pipeline to support subscriptions, defer and stream. (we鈥檒l likely want these to be runnable on top of http as well, possibly using sse or plain multipart responses.)

can you please give a hint on the docs that @defer is currently not working and a upcoming feature?

I'm curious if there is a reason to not release the client-side support on it's own, especially given that graphql-java just merged defer support.

Was this page helpful?
0 / 5 - 0 ratings