Skip to content

Commit

Permalink
deploy: ec65fb3
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp committed Jan 26, 2024
1 parent 197aec1 commit 6cd9f7a
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 10 deletions.
11 changes: 10 additions & 1 deletion docs/0.18/asgi.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ <h2><a class="anchor" aria-hidden="true" id="using-with-an-asgi-server"></a><a h
</code></pre>
<h2><a class="anchor" aria-hidden="true" id="configuration-options"></a><a href="#configuration-options" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Configuration options</h2>
<p>See the <a href="/docs/0.18/asgi-reference#constructor">reference</a>.</p>
<h2><a class="anchor" aria-hidden="true" id="the-request-instance"></a><a href="#the-request-instance" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>The <code>request</code> instance</h2>
<p>The ASGI application creates its own <code>request</code> object, an instance of the <code>Request</code> class from the <a href="https:/encode/starlette/blob/0.36.1/starlette/requests.py#L199">Starlette</a>. It's <code>scope</code> and <code>receive</code> attributes are populated from the received request.</p>
<p>When writing the <a href="https://asgi.readthedocs.io/en/latest/specs/main.html#middleware">ASGI middleware</a>, remember to rely on the <code>request.scope</code> dict for storing additional data on the request object, instead of mutating the request object directly (like it's done in Django). For example:</p>
<pre><code class="hljs css language-python"><span class="hljs-comment"># This is wrong</span>
request.app_data

<span class="hljs-comment"># This is correct</span>
request.scope[<span class="hljs-string">"app_data"</span>]
</code></pre>
<h2><a class="anchor" aria-hidden="true" id="customizing-json-responses"></a><a href="#customizing-json-responses" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Customizing JSON responses</h2>
<p>Ariadne's ASGI application uses <a href="https:/encode/starlette/blob/0.36.1/starlette/responses.py#L169">Starlette's <code>JSONResponse</code></a> for its JSON responses.</p>
<p>You can customize response creation logic by implementing a custom HTTP handler strategy for your ASGI GraphQL app.</p>
Expand Down Expand Up @@ -139,7 +148,7 @@ <h2><a class="anchor" aria-hidden="true" id="customizing-json-responses"></a><a
<p><strong>Note</strong>: the <code>GraphQLHTTPHandler</code> class implements many other methods that can be customized through inheritance.</p>
<p>See the <a href="/docs/0.18/asgi-handlers-reference#graphqlhttphandler">API reference</a> for a completed list.</p>
</blockquote>
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/0.18/continuous-security-testing"><span class="arrow-prev"></span><span>Continuous security testing</span></a><a class="docs-next button" href="/docs/0.18/wsgi"><span>WSGI application</span><span class="arrow-next"></span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#using-with-an-asgi-server">Using with an ASGI server</a></li><li><a href="#configuration-options">Configuration options</a></li><li><a href="#customizing-json-responses">Customizing JSON responses</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/icon.png" alt="Ariadne" height="107" width="128"/></a><div class="footerNavSpacer"></div><div class="footerNavTwoColumn"><h5>Documentation</h5><a href="/docs/intro.html">Introduction</a><a href="/docs/resolvers.html">Resolvers</a><a href="/docs/mutations.html">Mutations</a><a href="/docs/subscriptions.html">Subscriptions</a><a href="/docs/django-integration.html">Django integration</a><a href="/docs/flask-integration.html">Flask integration</a><a href="/docs/starlette-integration.html">Starlette integration</a><a href="/docs/other-integrations.html">Other integrations</a><a href="/docs/api-reference.html">API Reference</a><a href="/docs/logo.html">Logo</a></div><div><h5>Community</h5><a href="https:/mirumee/ariadne/discussions/">Discuss</a><a href="https:/mirumee/ariadne">GitHub</a><a class="github-button" href="https:/mirumee/ariadne" data-icon="octicon-star" data-count-href="/mirumee/ariadne/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><section class="copyright"><a href="https://mirumee.com">Copyright © 2024 Mirumee Software</a><a href="https://mirumee.com">Ariadne is crafted with love by<img src="/img/mirumee.png" alt="Mirumee"/></a></section></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>window.twttr=(function(d,s, id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js, fjs);t._e = [];t.ready = function(f) {t._e.push(f);};return t;}(document, 'script', 'twitter-wjs'));</script><script>
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/0.18/continuous-security-testing"><span class="arrow-prev"></span><span>Continuous security testing</span></a><a class="docs-next button" href="/docs/0.18/wsgi"><span>WSGI application</span><span class="arrow-next"></span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#using-with-an-asgi-server">Using with an ASGI server</a></li><li><a href="#configuration-options">Configuration options</a></li><li><a href="#the-request-instance">The <code>request</code> instance</a></li><li><a href="#customizing-json-responses">Customizing JSON responses</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/icon.png" alt="Ariadne" height="107" width="128"/></a><div class="footerNavSpacer"></div><div class="footerNavTwoColumn"><h5>Documentation</h5><a href="/docs/intro.html">Introduction</a><a href="/docs/resolvers.html">Resolvers</a><a href="/docs/mutations.html">Mutations</a><a href="/docs/subscriptions.html">Subscriptions</a><a href="/docs/django-integration.html">Django integration</a><a href="/docs/flask-integration.html">Flask integration</a><a href="/docs/starlette-integration.html">Starlette integration</a><a href="/docs/other-integrations.html">Other integrations</a><a href="/docs/api-reference.html">API Reference</a><a href="/docs/logo.html">Logo</a></div><div><h5>Community</h5><a href="https:/mirumee/ariadne/discussions/">Discuss</a><a href="https:/mirumee/ariadne">GitHub</a><a class="github-button" href="https:/mirumee/ariadne" data-icon="octicon-star" data-count-href="/mirumee/ariadne/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><section class="copyright"><a href="https://mirumee.com">Copyright © 2024 Mirumee Software</a><a href="https://mirumee.com">Ariadne is crafted with love by<img src="/img/mirumee.png" alt="Mirumee"/></a></section></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>window.twttr=(function(d,s, id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js, fjs);t._e = [];t.ready = function(f) {t._e.push(f);};return t;}(document, 'script', 'twitter-wjs'));</script><script>
document.addEventListener('keyup', function(e) {
if (e.target !== document.body) {
return;
Expand Down
11 changes: 10 additions & 1 deletion docs/0.18/asgi/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ <h2><a class="anchor" aria-hidden="true" id="using-with-an-asgi-server"></a><a h
</code></pre>
<h2><a class="anchor" aria-hidden="true" id="configuration-options"></a><a href="#configuration-options" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Configuration options</h2>
<p>See the <a href="/docs/0.18/asgi-reference#constructor">reference</a>.</p>
<h2><a class="anchor" aria-hidden="true" id="the-request-instance"></a><a href="#the-request-instance" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>The <code>request</code> instance</h2>
<p>The ASGI application creates its own <code>request</code> object, an instance of the <code>Request</code> class from the <a href="https:/encode/starlette/blob/0.36.1/starlette/requests.py#L199">Starlette</a>. It's <code>scope</code> and <code>receive</code> attributes are populated from the received request.</p>
<p>When writing the <a href="https://asgi.readthedocs.io/en/latest/specs/main.html#middleware">ASGI middleware</a>, remember to rely on the <code>request.scope</code> dict for storing additional data on the request object, instead of mutating the request object directly (like it's done in Django). For example:</p>
<pre><code class="hljs css language-python"><span class="hljs-comment"># This is wrong</span>
request.app_data

<span class="hljs-comment"># This is correct</span>
request.scope[<span class="hljs-string">"app_data"</span>]
</code></pre>
<h2><a class="anchor" aria-hidden="true" id="customizing-json-responses"></a><a href="#customizing-json-responses" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Customizing JSON responses</h2>
<p>Ariadne's ASGI application uses <a href="https:/encode/starlette/blob/0.36.1/starlette/responses.py#L169">Starlette's <code>JSONResponse</code></a> for its JSON responses.</p>
<p>You can customize response creation logic by implementing a custom HTTP handler strategy for your ASGI GraphQL app.</p>
Expand Down Expand Up @@ -139,7 +148,7 @@ <h2><a class="anchor" aria-hidden="true" id="customizing-json-responses"></a><a
<p><strong>Note</strong>: the <code>GraphQLHTTPHandler</code> class implements many other methods that can be customized through inheritance.</p>
<p>See the <a href="/docs/0.18/asgi-handlers-reference#graphqlhttphandler">API reference</a> for a completed list.</p>
</blockquote>
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/0.18/continuous-security-testing"><span class="arrow-prev"></span><span>Continuous security testing</span></a><a class="docs-next button" href="/docs/0.18/wsgi"><span>WSGI application</span><span class="arrow-next"></span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#using-with-an-asgi-server">Using with an ASGI server</a></li><li><a href="#configuration-options">Configuration options</a></li><li><a href="#customizing-json-responses">Customizing JSON responses</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/icon.png" alt="Ariadne" height="107" width="128"/></a><div class="footerNavSpacer"></div><div class="footerNavTwoColumn"><h5>Documentation</h5><a href="/docs/intro.html">Introduction</a><a href="/docs/resolvers.html">Resolvers</a><a href="/docs/mutations.html">Mutations</a><a href="/docs/subscriptions.html">Subscriptions</a><a href="/docs/django-integration.html">Django integration</a><a href="/docs/flask-integration.html">Flask integration</a><a href="/docs/starlette-integration.html">Starlette integration</a><a href="/docs/other-integrations.html">Other integrations</a><a href="/docs/api-reference.html">API Reference</a><a href="/docs/logo.html">Logo</a></div><div><h5>Community</h5><a href="https:/mirumee/ariadne/discussions/">Discuss</a><a href="https:/mirumee/ariadne">GitHub</a><a class="github-button" href="https:/mirumee/ariadne" data-icon="octicon-star" data-count-href="/mirumee/ariadne/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><section class="copyright"><a href="https://mirumee.com">Copyright © 2024 Mirumee Software</a><a href="https://mirumee.com">Ariadne is crafted with love by<img src="/img/mirumee.png" alt="Mirumee"/></a></section></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>window.twttr=(function(d,s, id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js, fjs);t._e = [];t.ready = function(f) {t._e.push(f);};return t;}(document, 'script', 'twitter-wjs'));</script><script>
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/0.18/continuous-security-testing"><span class="arrow-prev"></span><span>Continuous security testing</span></a><a class="docs-next button" href="/docs/0.18/wsgi"><span>WSGI application</span><span class="arrow-next"></span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#using-with-an-asgi-server">Using with an ASGI server</a></li><li><a href="#configuration-options">Configuration options</a></li><li><a href="#the-request-instance">The <code>request</code> instance</a></li><li><a href="#customizing-json-responses">Customizing JSON responses</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/icon.png" alt="Ariadne" height="107" width="128"/></a><div class="footerNavSpacer"></div><div class="footerNavTwoColumn"><h5>Documentation</h5><a href="/docs/intro.html">Introduction</a><a href="/docs/resolvers.html">Resolvers</a><a href="/docs/mutations.html">Mutations</a><a href="/docs/subscriptions.html">Subscriptions</a><a href="/docs/django-integration.html">Django integration</a><a href="/docs/flask-integration.html">Flask integration</a><a href="/docs/starlette-integration.html">Starlette integration</a><a href="/docs/other-integrations.html">Other integrations</a><a href="/docs/api-reference.html">API Reference</a><a href="/docs/logo.html">Logo</a></div><div><h5>Community</h5><a href="https:/mirumee/ariadne/discussions/">Discuss</a><a href="https:/mirumee/ariadne">GitHub</a><a class="github-button" href="https:/mirumee/ariadne" data-icon="octicon-star" data-count-href="/mirumee/ariadne/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><section class="copyright"><a href="https://mirumee.com">Copyright © 2024 Mirumee Software</a><a href="https://mirumee.com">Ariadne is crafted with love by<img src="/img/mirumee.png" alt="Mirumee"/></a></section></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>window.twttr=(function(d,s, id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js, fjs);t._e = [];t.ready = function(f) {t._e.push(f);};return t;}(document, 'script', 'twitter-wjs'));</script><script>
document.addEventListener('keyup', function(e) {
if (e.target !== document.body) {
return;
Expand Down
Loading

0 comments on commit 6cd9f7a

Please sign in to comment.