GithubHelp home page GithubHelp logo

midnight-factory / vscode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fauna/vscode

0.0 0.0 0.0 7.58 MB

FaunaDB extension for VS Code

License: Other

TypeScript 92.77% JavaScript 4.05% CSS 2.26% Shell 0.92%

vscode's Introduction

Source code for the Fauna VS Code extension.

This extension allows users to browse their Fauna databases and run FQL queries from directly inside VS Code.

Note: This extension does not yet support auto-complete, but this is planned for a future release. Alternatively, please feel free to submit a PR to help out!

Getting started

Prerequisites

  1. Create a Fauna account

  2. Install VS Code

  3. Install the Fauna extension in VS Code.

1. Set your secret key

You can persist a Fauna secret using either a .faunarc file in your project or using the settings in the VS Code IDE.

Persisting a secret in VS Code settings will set the key at a global level for all projects. A project can override the global key by including a .faunarc config file in the root of the project.

Using a .faunarc file for a project

  1. IMPORTANT: Add .faunarc to your .gitignore.
  2. Create a file .faunarc in your project root folder.
  3. Add the following code FAUNA_KEY=your-secret-key.

Additionally config might have optional parameters

FAUNA_DOMAIN=db.fauna.com
FAUNA_SCHEME=https
FAUNA_PORT=443
FAUNA_GRAPHQL_HOST=graphql.fauna.com

Using VS Code to store a global key

  1. To access to all of your databases from VS Code, you will need to create an account admin key from your Fauna Dashboard. Note: You can also provide VS Code access to an individual database by generating an admin key from that database's "Security" tab, but the extension does not support "server" keys at this time.

  2. Copy the secret and paste it into the Fauna extension settings. You can find the Fauna extension settings by either:

  • Selecting View > Extensions to open the Extensions pane, scrolling down in the list of installed extensions until you see Fauna, then clicking the cog icon in the lower right to open the extension settings.

  • Selecting Code > Preferences > Settings > Extensions > Fauna from the VS Code menu.

  1. Restart VS Code after setting or changing your secret.

Extension settings

  • fauna.adminSecretKey: The secret for a specific database.
  • fauna.domain: The hostname of endpoint’s Fauna instance
  • fauna.scheme: One of https or http
  • fauna.port: The UNIX port number of endpoint’s Fauna instance
  • fauna.graphqlHost: The hostname of Fauna GraphQL API

WARNING: Be careful! To avoid exposing this secret, do not commit it to your local .vscode configuration.

2. Browse database/s

  1. Click on the Fauna bird icon in the Activity bar on the far left. If you do not see the Activity Bar, select View > Appearance > Show Activity Bar from the VS Code menu.
  2. You should now see a pane listing all of your databases, indexes, collections, documents, and functions.

Note: Browsing is read-only at this time, but you can edit all of your data by running queries (see next section).

Browser your database data

3. Run queries

  1. Open the command palette with the keyboard shortcut Cmd + Shift + P if you are on a Mac (or Ctrl + Shift + P on a PC).

  2. Create a new file from which to run your FQL queries by either:

  • Typing Fauna: Create query to select that command from the command palette dropdown. This will open a new tab with the Paginate(Collections()) query already included.

  • Creating a new file with the .fql file extension.

  1. Open the command palette again (with Cmd + Shift + P), but this time start typing Fauna: Run query to select that command from the dropdown.

  2. The Output panel should open up from the bottom of the VS Code window, displaying the query's results.

Run queries

  1. If you have multiple FQL expressions in your file, you can also trigger them individually by highlighting the expression you want to execute.

Run selection query

4. Upload GraphQL Schema

  1. Open a .graphql or .gql file containing your GraphQL schema as per the Fauna specification.

  2. Open the command palette with the keyboard shortcut Cmd + Shift + P if you are on a Mac (or Ctrl + Shift + P on a PC).

  3. Fauna allows two modes of uploading schemas, and there are commands for each of these.

  • Type Fauna: Upload GraphQL Schema to upload in the default merge mode.

  • Or, type Fauna: Merge GraphQL Schema for explicitly uploading in merge mode.

  • Or, type Fauna: Override GraphQL Schema for uploading in override mode. (WARNING: override mode causes data loss for any previous GraphQL schema. Any collections, indexes, or documents that are not involved in GraphQL are not affected.)

Upload GraphQL schema

Features

Commands

  • Fauna: Create query
  • Fauna: Run query
  • Fauna: Upload GraphQL Schema
  • Fauna: Merge GraphQL Schema
  • Fauna: Override GraphQL Schema

Fauna commands

Built With

vscode's People

Contributors

fireridlle avatar brunoquaresma avatar ryancharris avatar parkhomenko avatar dependabot[bot] avatar n400 avatar aleclarson avatar gahabeen avatar macnealefauna avatar lewis-fauna avatar maestroartistryconsulting avatar armchair-traveller avatar danieltodonnell avatar gozala avatar jfloresremar avatar nksaraf avatar fauna-rodrigo avatar dependabot-preview[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.