UNPKG

fauna-gql-upload

Version:

Manage your FaunaDB resources in within your project and upload them using a single command

240 lines (178 loc) 8.41 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Upload schema - Fauna GQL Upload</title> <link rel="preconnect" href="https://cdnjs.cloudflare.com" /> <link rel="preconnect" href="https://arc.io" /> <link rel="preconnect" href="https://viewm.moonicorn.network" /> <link rel="preconnect" href="https://plausible.io" /> <link rel="stylesheet" href="../../css/main.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/themes/prism-okaidia.css" integrity="sha512-lTmd0bFMM2Ttm/S8V5dywYNiJaSyF5PILZosvAIzW4EJ7JLEYflk9ImyYIxw5KlFz7e9ZCJN53rnvPnefD240w==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/prism.min.js" integrity="sha512-YBk7HhgDZvBxmtOfUdvX0z8IH2d10Hp3aEygaMNhtF8fSOvBZ16D/1bXZTJV6ndk/L/DlXxYStP8jrF77v2MIg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script async src="https://arc.io/widget.min.js#3ua6mscf"></script> <script async defer data-domain="fgu-docs.com" src="https://plausible.io/js/plausible.js"></script> </head> <body> <header> <button class="icon-button hamburger"> <img src="../../img/hamburger.svg" /> </button> <h1 class="title">Fauna GQL Upload</h1> <div class="social"> <a href="https://github.com/Plazide/fauna-gql-upload"> <img alt="Github" src="../../img/github.png" /> </a> <a href="https://twitter.com/chj_web"> <img alt="Twitter" src="../../img/twitter.png" /> </a> </div> </header> <nav class="nav"> <header> <button onclick="toggleNavigation()" class="icon-button backburger"> <img src="../../img/backburger.svg" /> </button> <h1 class="title">Fauna GQL Upload</h1> </header> <ul class="list"> <li > <a href="../..">✨ Introduction</a> </li> <li > <a href="../../getting-started/">🏹 Getting started</a> </li> <li class="dropdown"> <button class="dropdown-button"> ⌨️ Configuration <img class="chevron" alt="chevron" src="../../img/chevron.svg" /> </button> <ul class="closed list"> <li > <a href="../../configuration/config-file/">Config file</a> </li> <li > <a href="../../configuration/command-line-options/">Command-line options</a> </li> <li > <a href="../../configuration/local-development/">Local development</a> </li> </ul> </li> <li class="active dropdown"> <button class="dropdown-button"> 🤹 Usage <img class="chevron" alt="chevron" src="../../img/chevron.svg" /> </button> <ul class="list"> <li class="active"> <a href="./">Upload schema</a> </li> <li > <a href="../upload-functions/">Upload functions</a> </li> <li > <a href="../upload-indexes/">Upload indexes</a> </li> <li > <a href="../upload-roles/">Upload roles</a> </li> <li > <a href="../upload-data/">Upload data</a> </li> <li > <a href="../upload-access-providers/">Upload access providers</a> </li> <li > <a href="../graphql-code-generator/">GraphQL code generator</a> </li> <li > <a href="../with-typescript/">With typescript</a> </li> </ul> </li> <li > <a href="../../contributing/">💡 Contributing</a> </li> <li > <a href="../../problems-or-issues/">❌ Problems or issues?</a> </li> </ul> <footer> <a href="https://github.com/Plazide/fauna-gql-upload"> <img alt="Github" src="../../img/github.png" /> </a> <a href="https://twitter.com/chj_web"> <img alt="Twitter" src="../../img/twitter.png" /> </a> </footer> </nav> <main class="main"><h1 id="upload-schema">Upload schema</h1> <p>To upload your schema, it has to be placed at <code>fauna/schema.gql</code> or the path specified in <code>.fauna.json</code>. It also needs to be valid, otherwise you would get back an error. For more information on writing a GraphQL schema for FaunaDB, see the <a href="https://docs.fauna.com/fauna/current/api/graphql/">official documentation</a>.</p> <h2 id="schema-modes">Schema modes</h2> <p>There are three different schema import modes. </p> <ol> <li><strong>Merge</strong>. creates missing collections, indexes, and functions. <em>This is the default</em>.</li> <li><strong>Override</strong>. This will delete all collections, indexes, and functions</li> <li><strong>Replace</strong>. This will replace metadata in collections, indexes, functions, and databases.</li> </ol> <p>Read more about <a href="https://docs.fauna.com/fauna/current/api/graphql/endpoints#modes">schema import modes</a>.</p> <p>Which import mode you want to use can be specified using the <code>--mode</code> option. Like so:</p> <pre><code class="language-bash">fgu --mode replace </code></pre> <h2 id="overriding-the-schema">Overriding the schema</h2> <p>If you need to make schema changes that are not compatible with the previous versions of the schema, you might have to override it. This can be done by adding a <code>--mode</code> flag when running the command.</p> <p>Like so:</p> <pre><code class="language-sh">fgu --mode override </code></pre> <p>Your npm script would then look like this:</p> <pre><code class="language-json">... &quot;scripts&quot;: { &quot;fauna&quot;: &quot;fgu&quot;, &quot;fauna-override&quot;: &quot;fgu --mode override&quot;, } ... </code></pre> <p>and then run:</p> <pre><code class="language-sh">npm run fauna-override </code></pre> <p>Since overriding the schema removes all collections, functions, and indexes, you will be asked to confirm your intention. In certain situations though, you'd want to skip this confirmation, like in a CI/CD pipeline. Therefore, you can use the <code>-y</code> flag to override the prompt and go forward with the operation without questions.</p> <p>It would look like this:</p> <pre><code class="language-sh">fgu --mode override -y </code></pre> <h2 id="concatenating-schema-files">Concatenating schema files</h2> <p>It is possible to separate the different parts of your schema into their own files. You could, for example, create a file called <code>queries.gql</code> that hold your query definitions and then create another file called <code>mutations.gql</code> that hold your mutation definitions. These files will then be concatenated into a single file before uploading the schema to Fauna.</p> <p>You need to add the <code>schemaDir</code> option to your <code>.fauna.json</code> file to use this feature. This option must point to a directory containing one or more graphql schema definition files with either a <code>.gql</code> or <code>.graphql</code> extension.</p> <p>When using the <code>schemaDir</code> option, the <code>schemaPath</code> option will be ignored. If neither of these are defined in <code>.fauna.json</code> the default <code>schemaPath</code> value will be used, which is <code>fauna/schema.gql</code>.</p> <p>A config file containing a <code>schemaDir</code> option could look like this:</p> <pre><code class="language-json">{ &quot;schemaDir&quot;: &quot;fauna/schema&quot; } </code></pre> <p>No other options need to be defined.</p> <p>You can also use a command-line option to specify the <code>schemaDir</code>, like so:</p> <pre><code class="language-sh">fgu --schemaDir fauna/schema </code></pre></main> <iframe src="https://viewm.moonicorn.network/#%7B%22options%22%3A%7B%22publisherAddr%22%3A%220x60C1D3c8E5FE51bEE5546F6240E18230be4C7Ab2%22%2C%22whitelistedTokens%22%3A%5B%220x6B175474E89094C44Da98b954EedeAC495271d0F%22%5D%2C%22whitelistedType%22%3A%22legacy_160x600%22%2C%22randomize%22%3Atrue%2C%22targeting%22%3A%5B%5D%2C%22width%22%3A%22160%22%2C%22height%22%3A%22600%22%2C%22minPerImpression%22%3A%220%22%2C%22fallbackUnit%22%3Anull%2C%22marketSlot%22%3A%22QmREYH6teaTWQF7uD7TfKuVvqRY3P5WauxDeHoQoJJJ4aA%22%7D%7D" width="160" height="600" scrolling="no" frameborder="0" style="border: 0;" class="ad-frame" onload="window.addEventListener('message', function(ev) { if (ev.data.hasOwnProperty('adexHeight') && ('https://viewm.moonicorn.network' === ev.origin)) { for (let f of document.getElementsByTagName('iframe')) { if (f.contentWindow === ev.source) { f.height = ev.data.adexHeight; } } } }, false)" ></iframe> <script src="../../js/main.js"></script> </body> </html>