<labelid="sidebar-toggle"class="icon-button"for="sidebar-toggle-anchor"title="Toggle Table of Contents"aria-label="Toggle Table of Contents"aria-controls="sidebar">
<ahref="../print.html"title="Print this book"aria-label="Print this book">
<iid="print-button"class="fa fa-print"></i>
</a>
</div>
</div>
<divid="search-wrapper"class="hidden">
<formid="searchbar-outer"class="searchbar-outer">
<inputtype="search"id="searchbar"name="searchbar"placeholder="Search this book ..."aria-controls="searchresults-outer"aria-describedby="searchresults-header">
<p>Once we have built a <ahref="../schema/index.html">GraphQL schema</a>, the next obvious step would be to serve it, so clients can interact with our <ahref="https://graphql.org">GraphQL</a> API. Usually, <ahref="https://graphql.org">GraphQL</a> APIs are served via <ahref="https://en.wikipedia.org/wiki/HTTP">HTTP</a>.</p>
<h2id="web-server-frameworks"><aclass="header"href="#web-server-frameworks">Web server frameworks</a></h2>
<p>Though the <ahref="https://docs.rs/juniper"><code>juniper</code></a> crate doesn't provide a built-in <ahref="https://en.wikipedia.org/wiki/HTTP">HTTP</a> server, the surrounding ecosystem does.</p>
<p><ahref="https://docs.rs/juniper">Juniper</a> officially supports the following widely used and adopted web server frameworks in <ahref="https://www.rust-lang.org">Rust</a> ecosystem:</p>
<p>See their API docs and usage examples (accessible from API docs) for further details of how they should be used.</p>
<blockquote>
<p><strong>NOTE</strong>: All the officially supported web server framework integrations provide a simple and convenient way for exposing <ahref="https://github.com/graphql/graphiql">GraphiQL</a> and/or <ahref="https://github.com/prisma/graphql-playground">GraphQL Playground</a> with the <ahref="../schema/index.html">GraphQL schema</a> along. These powerful tools ease the development process by enabling you to explore and send client requests to the <ahref="https://graphql.org">GraphQL</a> API under development.</p>
<p><strong>NOTE</strong>: <ahref="https://en.wikipedia.org/wiki/WebSocket">WebSocket</a> is a crucial part for serving <ahref="../schema/subscriptions.html">GraphQL subscriptions</a> over <ahref="https://en.wikipedia.org/wiki/HTTP">HTTP</a>.</p>
</blockquote>
<p>There are two widely adopted protocols for serving <ahref="https://graphql.org">GraphQL</a> over <ahref="https://en.wikipedia.org/wiki/WebSocket">WebSocket</a>:</p>
<ol>
<li><ahref="https://github.com/apollographql/subscriptions-transport-ws/blob/v0.11.0/PROTOCOL.md">Legacy <code>graphql-ws</code> GraphQL over WebSocket Protocol</a>, formerly used by <ahref="https://www.apollographql.com">Apollo</a> and the <ahref="https://npmjs.com/package/subscriptions-transport-ws"><code>subscriptions-transport-ws</code> npm package</a>, and now being deprecated.</li>
<li><ahref="https://github.com/enisdenjo/graphql-ws/blob/v5.14.0/PROTOCOL.md">New <code>graphql-transport-ws</code> GraphQL over WebSocket Protocol</a>, provided by the <ahref="https://npmjs.com/package/graphql-ws"><code>graphql-ws</code> npm package</a> and being used by <ahref="https://www.apollographql.com">Apollo</a> as for now.</li>
</ol>
<p>In the <ahref="https://docs.rs/juniper">Juniper</a> ecosystem, both implementations are provided by the <ahref="https://docs.rs/juniper_graphql_ws"><code>juniper_graphql_ws</code></a> crate. Most of the <ahref="#officially-supported">officially supported web server framework integrations</a> are able to serve a <ahref="../schema/index.html">GraphQL schema</a> over <ahref="https://en.wikipedia.org/wiki/WebSocket">WebSocket</a> (including <ahref="../schema/subscriptions.html">subscriptions</a>) and even support <ahref="https://developer.mozilla.org/docs/Web/API/WebSockets_API/Writing_WebSocket_servers#subprotocols">auto-negotiation of the correct protocol based on the <code>Sec-Websocket-Protocol</code> HTTP header value</a>. See their API docs and usage examples (accessible from API docs) for further details of how to do so.</p>