UNPKG

fauna-gql-upload

Version:

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

255 lines (193 loc) 9.56 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>🏹 Getting started - 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 class="active"> <a href="./">🏹 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="dropdown"> <button class="dropdown-button"> 🤹 Usage <img class="chevron" alt="chevron" src="../img/chevron.svg" /> </button> <ul class="closed list"> <li > <a href="../usage/upload-schema/">Upload schema</a> </li> <li > <a href="../usage/upload-functions/">Upload functions</a> </li> <li > <a href="../usage/upload-indexes/">Upload indexes</a> </li> <li > <a href="../usage/upload-roles/">Upload roles</a> </li> <li > <a href="../usage/upload-data/">Upload data</a> </li> <li > <a href="../usage/upload-access-providers/">Upload access providers</a> </li> <li > <a href="../usage/graphql-code-generator/">GraphQL code generator</a> </li> <li > <a href="../usage/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="getting-started">🏹 Getting started</h1> <h2 id="initialize-fauna-gql-upload">Initialize Fauna GQL Upload</h2> <p>It is possible, as of version 2.5.0, to run an initialization command that, based on a few questions, creates the desired folders and configuration files. Simply run: </p> <pre><code class="language-sh">yarn fgu init </code></pre> <p>or </p> <pre><code class="language-sh">npx fgu init </code></pre> <p>and answer the questions that are presented. This will create the folders you need and create a config file with the correct options. If you don't want to answer the questions and you're happy with the defaults, simply add the <code>-y</code> flag to the command. Like so:</p> <pre><code class="language-sh">yarn fgu init -y </code></pre> <p>You could, of course, completely ignore the init command and create the folders and configuration files yourself. The init command could be a good way to familiarize yourself with the folder structure.</p> <blockquote> <p><strong>NOTE:</strong> This command creates placeholder resources. Remember to edit or delete these before uploading.</p> </blockquote> <h2 id="manual-setup">Manual setup</h2> <h3 id="installation">Installation</h3> <p>Fauna GQL Upload needs a local installation of <code>faunadb</code>. That means you need to install both <code>fauna-gql-upload</code> and <code>faunadb</code>.</p> <p>With npm:</p> <pre><code class="language-sh">npm install --save-dev fauna-gql-upload faunadb </code></pre> <p>With yarn:</p> <pre><code class="language-sh">yarn add -D fauna-gql-upload faunadb </code></pre> <blockquote> <p><strong>NOTE:</strong> You do not need to install <code>faunadb</code> as a development dependency. You could also install it normally if you use it as part of your frontend or in other backend code.</p> </blockquote> <h3 id="adding-npm-script">Adding npm script</h3> <p>You will need to add an npm script to the command.</p> <p>Package.json:</p> <pre><code class="language-js">... &quot;scripts&quot;: { &quot;fauna&quot;: &quot;fgu&quot; // you can use 'fgu' or 'fauna-gql' } ... </code></pre> <p>Running it:</p> <pre><code class="language-sh">npm run fauna </code></pre> <p>or:</p> <pre><code class="language-sh">yarn fauna </code></pre> <h3 id="files-and-directories">Files and directories</h3> <p>For the command to work properly, you need to have certain information in your project.</p> <ul> <li>You need a <code>.env</code> file with a variable called <code>FGU_SECRET</code>. This should be an admin key for your database. <strong><em>This is required</em></strong> </li> <li>To upload a schema, you need a valid schema file. This file should be located at <code>fauna/schema.gql</code> relative to the working directory where the command is executed. See <a href="/usage/upload-schema">Uploading schema</a> for more info. It is also possible to create a <em>folder</em> called <code>schema</code> and divide your schema into multiple files that will be automatically concatenated before upload.</li> <li>To upload functions, you need a directory called <code>fauna/functions</code>. Within this directory, you should have one <code>.js</code>/<code>.ts</code> file for each of your functions. See <a href="/usage/upload-functions">Uploading Functions</a> for an example of such a file.</li> <li>To upload roles, you need a directory called <code>fauna/roles</code>. Within this directory, you should have one <code>.js</code>/<code>.ts</code> file for each of your roles. See <a href="/usage/upload-roles">Uploading Roles</a> for an example of such a file.</li> <li>To upload indexes, you need a directory called <code>fauna/indexes</code>. Within this directory, you should have one <code>.js</code>/<code>.ts</code> file for each of your indexes. See <a href="/usage/upload-indexes">Uploading indexes</a> for an example of such a file.</li> <li>To upload domain data, you need a directory called <code>fauna/data</code>. Within this directory, you should have one <code>.js</code>/<code>.ts</code> file for each of your data sets. See <a href="/usage/upload-data">Uploading data</a> for an example of such a file.</li> <li>To upload access providers, you need a directory called <code>fauna/providers</code>. Within this directory, you should have one <code>.js</code>/<code>.ts</code> file for each of your providers. See <a href="/usage/upload-access-providers">Uploading access providers</a> for an example of such a file.</li> </ul> <h2 id="usage">Usage</h2> <p>To upload your resources, simply run the previously configured command. For example, if your npm script is called <code>fauna</code> run the following.</p> <p>with npm:</p> <pre><code class="language-sh">npm run fauna </code></pre> <p>with yarn:</p> <pre><code class="language-sh">yarn fauna </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>