### Set up GraphiQL.app for local development Source: https://github.com/skevy/graphiql-app To set up the GraphiQL.app project for local development, first clone the repository and navigate into its directory. Then, install all required Node.js packages, build the project, and finally start the application. ```npm npm i npm run build npm start ``` -------------------------------- ### Run Dgraph Docker Standalone Image Source: https://docs.hypermode.com/dgraph/guides/get-started-with-dgraph/introduction Quickly start Dgraph using the `dgraph/standalone` Docker image. This setup is for quickstart purposes only and not recommended for production. Ensure Docker is installed and running before executing this command. ```shellscript docker run --rm -it -p 8080:8080 -p 9080:9080 dgraph/standalone:latest ``` -------------------------------- ### GraphiQL App Development Workflow Commands Source: https://github.com/skevy/graphiql-app A sequence of commands to set up and run the GraphiQL application for local development. This includes installing Node.js dependencies, building the project, and starting the development server. ```bash npm i npm run build npm start ``` -------------------------------- ### Run HotROD Demo with Jaeger using Docker Compose Source: https://www.jaegertracing.io/docs/getting-started/ This set of commands clones the Jaeger repository, navigates to the HotROD example directory, and starts the HotROD demo application along with Jaeger using Docker Compose. This provides a complete environment to explore distributed tracing with OpenTelemetry instrumentation. ```bash export JAEGER_VERSION=2.7.0 #Pick the newest version git clone https://github.com/jaegertracing/jaeger.git jaeger cd jaeger/examples/hotrod docker compose up # press Ctrl-C to exit ``` -------------------------------- ### Run Yarn Commands to Install and Start React App Source: https://github.com/dgraph-io/discuss-tutorial Execute these commands in your terminal to first install all project dependencies using Yarn, and then launch the React application. By default, the app connects to the development backend, but can be configured to point to the production server locally. ```Shell yarn install yarn start ``` -------------------------------- ### Run React App with Yarn Source: https://github.com/dgraph-io/discuss-tutorial Instructions to install dependencies and start the React application locally using Yarn. This will bring up the app pointed at the development backend, or can be swapped to point at the production server. ```Shell yarn install yarn start ``` -------------------------------- ### Install Node.js Project Dependencies Source: https://github.com/hypermodeinc/dgraph-js/tree/main/examples/simple/README This command uses npm to install all required packages listed in the project's package.json file. This is a standard step for setting up Node.js projects. ```shell npm install ``` -------------------------------- ### Go: Partial Example of Dgraph Client Setup Source: https://godoc.org/github.com/dgraph-io/dgo This is a partial Go example demonstrating the `getDgraphClient` function for establishing a connection to a Dgraph instance and handling authentication. This function is typically used as a prerequisite for performing Dgraph operations. ```Go package main import ( "context" "encoding/json" "fmt" "log" "strings" "time" "github.com/dgraph-io/dgo" "github.com/dgraph-io/dgo/protos/api" "google.golang.org/grpc" ) type CancelFunc func() func getDgraphClient() (*dgo.Dgraph, CancelFunc) { conn, err := grpc.Dial("127.0.0.1:9180", grpc.WithInsecure()) ``` -------------------------------- ### Install Badger Go Library Source: https://github.com/hypermodeinc/badger Instructions to install the Badger Go library using `go get`. This requires Go 1.21 or above and Go modules. Running this command will retrieve the library into your project. ```shell go get github.com/dgraph-io/badger/v4 ``` -------------------------------- ### Install MinIO Helm Chart for Toy Setup Source: https://github.com/minio/minio/tree/master/helm/minio This command deploys a minimal MinIO setup suitable for testing purposes. It configures resource requests, sets replicas to 1, disables persistence, and runs in standalone mode, along with setting root user credentials. ```shell helm install --set resources.requests.memory=512Mi --set replicas=1 --set persistence.enabled=false --set mode=standalone --set rootUser=rootuser,rootPassword=rootpass123 --generate-name minio/minio ``` -------------------------------- ### Install Dgraph Go Client Source: https://godoc.org/github.com/dgraph-io/dgo Instructions to install the official Dgraph Go client using the `go get` command. Note that dgo 1.0.0 is compatible with dgraph 1.0.x. ```Go go get -u -v github.com/dgraph-io/dgo ``` -------------------------------- ### Set Up Local Development for GraphQL Playground React Component Source: https://github.com/prisma/graphql-playground Commands to set up and start local development for the `graphql-playground-react` package. This involves navigating to the package directory, installing dependencies, and starting the development server. ```shell $ cd packages/graphql-playground-react $ yarn $ yarn start ``` -------------------------------- ### Install pydgraph Python Client Source: https://github.com/hypermodeinc/pydgraph/tree/main/examples/simple This command installs the `pydgraph` Python client library using pip, which is necessary to interact with a Dgraph instance from Python applications. ```shell pip install pydgraph ``` -------------------------------- ### Dgraph Documentation Navigation Structure Source: https://docs.hypermode.com/dgraph/guides/get-started-with-dgraph/introduction This section outlines the main categories and sub-sections of the Dgraph documentation, providing a hierarchical overview of topics ranging from getting started and connecting to Dgraph, to query languages (DQL, GraphQL), administration, and available tools. ```APIDOC Dgraph Documentation: Getting Started: - Overview - Why Dgraph? - Quickstart - Guides - v25 Preview Connecting: - Overview - Go SDK - Python SDK - Java SDK - JavaScript SDK - .NET SDK - HTTP Query Language (DQL): - JSON Data Format - RDF Data Format - Schema - Indexes - Query - Mutation - Upsert - Facets and Edge Attributes - Keywords - Tips and Tricks GraphQL-based Development: - GraphQL API Overview - Quickstart - Connecting - Schema - Queries - Mutations - Subscriptions - Security - Lambda Administration: - Retrieve Schema - Update Types - Drop Data - Observability - Data Migration - Self-Managed Deployments Tools: - Ratel - CLI ``` -------------------------------- ### Run Dgraph Standalone Docker Image Source: https://docs.hypermode.com/dgraph/guides/get-started-with-dgraph/introduction This command starts a Dgraph standalone instance using Docker, exposing ports 8080 (HTTP) and 9080 (gRPC). The --rm flag removes the container upon exit, and -it runs it interactively. This image is for quickstarts, not production. ```bash docker run --rm -it -p 8080:8080 -p 9080:9080 dgraph/standalone:latest ``` -------------------------------- ### Install Apollo Client and GraphQL Dependencies Source: https://github.com/apollographql/apollo-client This command installs the `@apollo/client` package, which is the core library for Apollo Client, and `graphql`, which is a peer dependency required for GraphQL operations. Use this command in your project directory to get started with Apollo Client. ```bash npm install @apollo/client graphql ``` -------------------------------- ### Initialize and Start Dgraph Zero Server Source: https://github.com/hypermodeinc/dgraph4j/tree/main/samples/DgraphJavaSample This command initializes and starts the Dgraph Zero server. It first navigates to the Dgraph Zero data directory, removes any existing Zero data, and then launches the Dgraph Zero process. ```shell cd dgraphdata/zero rm -rf zw; dgraph zero ``` -------------------------------- ### Install Node.js Project Dependencies Source: https://github.com/hypermodeinc/dgraph-js/tree/main/examples/simple Installs all required Node.js packages listed in the project's `package.json` file. This command uses npm to download and set up the dependencies. ```npm npm install ``` -------------------------------- ### Start Dgraph Zero Instance Source: https://github.com/hypermodeinc/dgraph-js/tree/main/examples/simple Navigates to the Dgraph Zero data directory, removes any previous Zero data, and starts the Dgraph Zero process. Dgraph Zero manages cluster metadata and ensures data consistency. ```shell cd local-dgraph-data/zero rm -r zw; dgraph zero ``` -------------------------------- ### Dgraph Go Client: Initialize Schema for Facets Example Source: https://godoc.org/github.com/dgraph-io/dgo This Go example demonstrates how to initialize a Dgraph database for a new example, specifically by performing a `DropAll` operation to clear existing data and then defining a basic schema with an indexed 'name' predicate. This setup is typically used as a prerequisite for examples involving Dgraph facets. ```Go package main import ( "context" "encoding/json" ``` -------------------------------- ### Install GraphiQL.app on Linux Source: https://github.com/skevy/graphiql-app Install GraphiQL.app on Linux using the AppImage format. Download the AppImage binary, make it executable, and then run it. The application will prompt to add shortcuts for easier future access. ```Shell chmod +x graphiql-app-0.7.2-x86_64.AppImage ``` -------------------------------- ### Go: Get Dgraph Schema Source: https://godoc.org/github.com/dgraph-io/dgo This Go example demonstrates how to connect to a Dgraph server, define a schema, and then query for existing schema predicates. It shows the basic setup for a Dgraph client and performing an Alter operation followed by a Query to retrieve schema details. ```Go package main import ( "context" "fmt" "log" "github.com/dgraph-io/dgo" "github.com/dgraph-io/dgo/protos/api" "google.golang.org/grpc" ) func main() { conn, err := grpc.Dial("127.0.0.1:9180", grpc.WithInsecure()) if err != nil { log.Fatal("While trying to dial gRPC") } defer conn.Close() dc := api.NewDgraphClient(conn) dg := dgo.NewDgraphClient(dc) op := &api.Operation{} op.Schema = "\n\t\tname: string @index(exact) .\n\t\tage: int .\n\t\tmarried: bool .\n\t\tloc: geo .\n\t\tdob: datetime .\n\t" ctx := context.Background() err = dg.Alter(ctx, op) if err != nil { log.Fatal(err) } // Ask for the type of name and age. resp, err := dg.NewTxn().Query(ctx, "schema(pred: [name, age]) {type}") if err != nil { log.Fatal(err) } // resp.Json contains the schema query response. fmt.Println(string(resp.Json)) } ``` ```JSON {"schema":[{"predicate":"age","type":"int"},{"predicate":"name","type":"string"}]} ``` -------------------------------- ### Run Dgraph Standalone Docker Image Source: https://docs.hypermode.com/dgraph/guides/get-started-with-dgraph/introduction This command launches a Dgraph standalone instance using Docker. It maps ports 8080 (HTTP) and 9080 (gRPC) from the container to the host, and uses the latest `dgraph/standalone` image. The `--rm` flag ensures the container is removed upon exit, making it suitable for quickstart and testing, but not for production environments. ```shellscript docker run --rm -it -p 8080:8080 -p 9080:9080 dgraph/standalone:latest ``` -------------------------------- ### Start Dgraph Alpha Instance Source: https://github.com/hypermodeinc/dgraph-js/tree/main/examples/simple Navigates to the Dgraph Alpha data directory, removes any previous Alpha data, and starts the Dgraph Alpha process. Dgraph Alpha handles data storage and query execution, connecting to the Zero instance on localhost:5080. ```shell cd local-dgraph-data/data rm -r p w; dgraph alpha --zero localhost:5080 ``` -------------------------------- ### Install Node.js Project Dependencies Source: https://github.com/dgraph-io/dgraph-js-http/tree/master/examples/simple This command uses the Node Package Manager (npm) to install all the required dependencies for the sample application. This step must be completed before attempting to run any of the Node.js sample code. ```shell npm install ``` -------------------------------- ### Start Dgraph Zero Service Source: https://github.com/dgraph-io/dgraph-js-http/tree/master/examples/simple This shell snippet first changes the directory to `local-dgraph-data/zero`, then removes any previous working directory data (`zw`) to ensure a clean start, and finally launches the Dgraph Zero service. Dgraph Zero is essential for managing the Dgraph cluster's metadata. ```shell cd local-dgraph-data/zero rm -r zw; dgraph zero ``` -------------------------------- ### Start Dgraph Alpha Server Source: https://github.com/hypermodeinc/dgraph4j/tree/main/samples/DgraphJavaSample/README Navigates to the Dgraph Alpha data directory, removes previous data ('p' and 'w') for a clean setup, and starts the Dgraph Alpha server. It connects to the Dgraph Zero instance at 'localhost:5080' and shifts default ports by 100 (e.g., HTTP on 8180, GRPC on 9180) to avoid conflicts. ```Shell cd dgraphdata/data rm -rf p w; dgraph alpha --zero localhost:5080 -o 100 ``` -------------------------------- ### Execute TLS Example Python Script Source: https://github.com/hypermodeinc/pydgraph/tree/main/examples/tls This command runs the Python script `tls_example.py`, which demonstrates the TLS communication with the Dgraph cluster. Ensure Python is installed and the script is located in the current directory or its path is specified. ```shell python tls_example.py ``` -------------------------------- ### Start Dgraph Alpha Service Source: https://github.com/dgraph-io/dgraph-js-http/tree/master/examples/simple This shell snippet changes the directory to `local-dgraph-data/data`, removes any previous predicate or write-ahead log data (`p w`), and then starts the Dgraph Alpha service. The Alpha instance connects to the Dgraph Zero service running on `localhost:5080` to form the complete Dgraph cluster. ```shell cd local-dgraph-data/data rm -r p w; dgraph alpha --zero localhost:5080 ``` -------------------------------- ### Launch Dgraph Ratel UI Docker Image Source: https://docs.hypermode.com/dgraph/guides/get-started-with-dgraph/introduction This command starts the Dgraph Ratel UI in a Docker container, exposing port 8000. Ratel is Dgraph's web-based UI for interacting with the database. Access it via http://localhost:8000 after running. ```bash docker run --rm -d -p 8000:8000 dgraph/ratel:latest ``` -------------------------------- ### Run Jaeger Docker Container with Custom Configuration Source: https://www.jaegertracing.io/docs/getting-started/ This command demonstrates how to run the Jaeger all-in-one Docker container, mapping necessary ports and mounting a local configuration file. It allows Jaeger to be started with specific settings defined in config.yaml for different roles or advanced deployments. ```docker docker run --rm --name jaeger \ -p 16686:16686 \ -p 4317:4317 \ -p 4318:4318 \ -p 5778:5778 \ -p 9411:9411 \ -v /path/to/local/config.yaml:/jaeger/config.yaml \ jaegertracing/jaeger:2.7.0 \ --config /jaeger/config.yaml ``` -------------------------------- ### Start Dgraph Zero Node (Shell) Source: https://github.com/hypermodeinc/dgraph-js/tree/main/examples/simple/README This sequence of commands navigates into the 'local-dgraph-data/zero' directory, removes any existing 'zw' directory to ensure a fresh start, and then initiates the Dgraph Zero node. The Zero node is crucial for managing cluster membership and providing timestamps in a Dgraph cluster. ```shell cd local-dgraph-data/zero rm -r zw; dgraph zero ``` -------------------------------- ### Start Dgraph Alpha Server with Custom Ports Source: https://github.com/hypermodeinc/dgraph4j/tree/main/samples/DgraphJavaSample This command starts the Dgraph Alpha server. It navigates to the Alpha data directory, clears existing data, and then starts the Alpha server, connecting to the Zero server at localhost:5080 and shifting default ports by 100 (e.g., HTTP on 8180, GRPC on 9180). ```shell cd dgraphdata/data rm -rf p w; dgraph alpha --zero localhost:5080 -o 100 ``` -------------------------------- ### Regex X-mode Comment Example Source: https://www.geeksforgeeks.org/write-regular-expressions/ Illustrates a regular expression pattern using X-mode, where the '#' character is used to add inline comments that are ignored by the regex engine. The example matches words starting with 'A'. ```Regex (?x)\bA\w+\b#Matches words starting with A ``` -------------------------------- ### Install Go Snappy Library and Command-Line Tool Source: https://github.com/golang/snappy Instructions to install the Snappy Go library for use in Go projects and the `snappytool` command-line utility for direct file compression and decompression operations. ```Shell go get github.com/golang/snappy ``` ```Shell go install github.com/golang/snappy/cmd/snappytool@latest ``` -------------------------------- ### Dgraph Documentation Overview Source: https://docs.hypermode.com/dgraph/graphql/schema/directives/auth Overview of Dgraph, its benefits, quickstart guides, and general documentation. ```APIDOC Dgraph Documentation: Overview: /dgraph/overview Why Dgraph?: /dgraph/why-dgraph Description: Developers at startups to Fortune 500 companies choose Dgraph for their most intensive graph features. Quickstart: /dgraph/quickstart Guides: /dgraph/guides v25 Preview: /dgraph/v25-preview ``` -------------------------------- ### Go: Open and Interact with Badger DB Example Source: https://pkg.go.dev/github.com/dgraph-io/badger/v3 Demonstrates how to open a new Badger DB instance, perform read and write operations using transactions, and handle potential errors. The example shows how to set and retrieve a key-value pair and verifies the ErrKeyNotFound behavior. ```Go func Open(opt Options) (*DB, error) // Example: dir, err := ioutil.TempDir("", "badger-test") if err != nil { panic(err) } defer removeDir(dir) db, err := Open(DefaultOptions(dir)) if err != nil { panic(err) } defer db.Close() err = db.View(func(txn *Txn) error { _, err := txn.Get([]byte("key")) // We expect ErrKeyNotFound fmt.Println(err) return nil }) if err != nil { panic(err) } txn := db.NewTransaction(true) // Read-write txn err = txn.SetEntry(NewEntry([]byte("key"), []byte("value"))) if err != nil { panic(err) } err = txn.Commit() if err != nil { panic(err) } err = db.View(func(txn *Txn) error { item, err := txn.Get([]byte("key")) if err != nil { return err } val, err := item.ValueCopy(nil) if err != nil { return err } fmt.Printf("%s\n", string(val)) return nil }) if err != nil { panic(err) } // Output: // Key not found // value ``` -------------------------------- ### Regex: Match Start of String with Anchors Source: https://www.geeksforgeeks.org/write-regular-expressions/ Demonstrates the use of anchors to specify the position of a match within a string. Example shows matching a word at the beginning of the string using ^. ```Regex ^Hello ``` -------------------------------- ### Initialize Dgraph Alpha Server Source: https://github.com/hypermodeinc/dgraph-js/tree/main/examples/simple/README This command sequence navigates to the Dgraph data directory, clears any existing data, and then starts a Dgraph Alpha server instance. The --zero localhost:5080 flag specifies the address of the Dgraph Zero server. ```shell cd local-dgraph-data/data rm -r p w; dgraph alpha --zero localhost:5080 ``` -------------------------------- ### Deploy Jaeger All-in-One with Docker Source: https://www.jaegertracing.io/docs/getting-started/ This command starts a Jaeger all-in-one container, combining the collector and query components with transient in-memory storage. It maps necessary ports for the UI (16686), OTLP (4317, 4318), TChannel (5778), and Zipkin (9411) to the host. The --rm flag ensures the container is removed upon exit, and --name jaeger assigns a memorable name. ```shell docker run --rm --name jaeger \ -p 16686:16686 \ -p 4317:4317 \ -p 4318:4318 \ -p 5778:5778 \ -p 9411:9411 \ jaegertracing/jaeger:2.7.0 ``` -------------------------------- ### Install GraphQL Playground using Homebrew Source: https://github.com/prisma/graphql-playground This command demonstrates how to install the GraphQL Playground desktop application on macOS using Homebrew Cask. It provides a quick and easy way to get started with the IDE for GraphQL development. ```Shell $ brew install --cask graphql-playground ``` -------------------------------- ### Escaping Metacharacters in Regex Source: https://www.geeksforgeeks.org/write-regular-expressions/ Provides an example of escaping a metacharacter to treat it as a literal character within a regular expression. ```Regular Expressions \. ``` -------------------------------- ### Install BadgerDB Command Line Tool Source: https://pkg.go.dev/github.com/dgraph-io/badger/v3 These commands navigate into the Badger repository and install the Badger CLI utility into your $GOBIN path. Ensure you have checked out the desired version of the repository before running. ```Go cd badger go install . ``` -------------------------------- ### Example JSON Configuration Snippet Source: https://github.com/dgraph-io/discuss-tutorial A small JSON configuration object found within the document, likely representing a simple setting such as the resolved server color mode. ```JSON {"resolvedServerColorMode":"day"} ``` -------------------------------- ### Quick Start Dgraph Helm Deployment Source: https://github.com/dgraph-io/charts/ Provides a quick way to add the Dgraph Helm repository and install a Dgraph release on Kubernetes. This is the fastest method to get Dgraph running in your cluster. ```bash helm repo add dgraph https://charts.dgraph.io helm install my-release dgraph/dgraph ``` -------------------------------- ### Install Badger Bench Go Tool Source: https://github.com/dgraph-io/badger-bench This command uses the Go package manager to fetch and install the `badger-bench` tool, which is specifically designed for benchmarking BadgerDB. This step is crucial for setting up the environment to run performance tests. ```bash $ go get github.com/dgraph-io/badger-bench/... ``` -------------------------------- ### Install Kube-State-Metrics Project with Go Get Source: https://github.com/kubernetes/kube-state-metrics Install this project to your $GOPATH using go get: ```bash go get k8s.io/kube-state-metrics ``` -------------------------------- ### Install and Compile Badger Bench Source: https://github.com/dgraph-io/badger-bench Commands to fetch the Badger Bench Go package and then compile it to ensure all dependencies are met and the project builds successfully. ```Shell go get github.com/dgraph-io/badger-bench/... ``` ```Shell go test -c ``` -------------------------------- ### GraphQL Query to Find Entities with 'age' Predicate Source: https://docs.hypermode.com/dgraph/guides/get-started-with-dgraph/introduction This GraphQL query illustrates the use of the 'has' function to find all entities that have an 'age' predicate. This is analogous to the previous example, showing the flexibility of the 'has' function with different predicates. ```graphql { people(func: has(age)) { ``` -------------------------------- ### Dgraph JSON Data Mutation Example Source: https://docs.hypermode.com/dgraph/guides/get-started-with-dgraph/introduction This JSON snippet illustrates a 'set' mutation in Dgraph, used to add or update data. It shows how to insert a new node with 'name' and 'age' predicates. Note: The provided snippet is incomplete. ```json { "set": [ { "name": "Balaji", "age": 23 ``` -------------------------------- ### Example JSON Configuration Source: https://github.com/golang/snappy This is a simple JSON object demonstrating a server color mode setting. It's likely used for client-side configuration or API responses. ```JSON {"resolvedServerColorMode":"day"} ``` -------------------------------- ### Regex: Specify Number of Occurrences with Quantifiers Source: https://www.geeksforgeeks.org/write-regular-expressions/ Explains how quantifiers specify the number of times a character or group must appear. Example demonstrates matching exactly three digits using \d{3}. ```Regex \d{3} ``` -------------------------------- ### Directly Access and Manipulate Facets in C# Source: https://github.com/schivei/dgraph4net This section provides examples for directly getting and setting facet values on an object using methods like GetFacet and SetFacet. It also demonstrates how to handle internationalization (i18n) facets by using an '@' symbol in the facet name. ```C# var mc = new MyClass(); // - Getter mc.GetFacet("property|facet", defaultValue); mc.GetFacet(m => m.Property, "facet", defaultValue); // - Setter mc.SetFacet("property|facet", value); mc.SetFacet(m => m.Property, "facet", value); // - i18n, use an 'at' (@) instead of a 'pipe' (|); if using expression selection, put the 'at' at the start of facet name // - Getter mc.GetFacet("property@es", defaultValue); mc.GetFacet(m => m.Property, "@es", defaultValue); // - Setter mc.SetFacet("property@es", value); mc.SetFacet(m => m.Property, "@es", value); ``` -------------------------------- ### Example Output of kubectl get service Command Source: https://docs.microsoft.com/azure/aks/internal-lb An example of the output from 'kubectl get service', showing the service name, type, cluster IP, external IP, ports, and age. ```Text NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE internal-app LoadBalancer 10.0.184.168 10.240.0.25 80:30225/TCP 4m ``` -------------------------------- ### Start Dgraph Cluster Locally Source: https://github.com/hypermodeinc/pydgraph/tree/main/examples/simple This command initiates a local Dgraph cluster using Docker Compose. It's important to note that the security flag used here enables a blanket whitelist for testing convenience and should not be used in a production environment. ```Shell docker compose up ``` -------------------------------- ### Install Helm on Debian/Ubuntu using Apt Source: https://helm.sh/docs/intro/install/ Install Helm on Debian or Ubuntu systems by adding the official Helm Apt repository, importing the GPG key, updating package lists, and then installing Helm. This ensures you get the latest stable version. ```shell curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null sudo apt-get install apt-transport-https --yes echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list sudo apt-get update sudo apt-get install helm ``` -------------------------------- ### Install project dependencies with npm Source: https://github.com/hypermodeinc/dgraph-js/tree/main/examples/tls This command installs all necessary Node.js packages and dependencies required to run the Mutual TLS example project. Ensure you have Node.js and npm installed before running. ```shell npm install ``` -------------------------------- ### Start Dgraph Zero Server Source: https://github.com/hypermodeinc/dgraph4j/tree/main/samples/DgraphJavaSample/README Navigates to the Dgraph Zero data directory, removes any previous working directory ('zw') to ensure a fresh start, and then launches the Dgraph Zero server. This command initializes the Dgraph cluster's coordination service. ```Shell cd dgraphdata/zero rm -rf zw; dgraph zero ``` -------------------------------- ### Install GraphiQL.app on macOS Source: https://github.com/skevy/graphiql-app Install GraphiQL.app on macOS using Homebrew. This command adds the application to your system via a Homebrew Cask. Alternatively, a binary can be downloaded directly from the official releases page. ```Shell brew install --cask graphiql ``` -------------------------------- ### Run Node.js Sample with Promises Source: https://github.com/dgraph-io/dgraph-js-http/tree/master/examples/simple Executes the `index-promise.js` Node.js sample file. This version of the sample code uses Promise-based syntax, providing an alternative for environments that may not fully support `async/await`. ```shell node index-promise.js ``` -------------------------------- ### Anchor Regex to Start of String Source: https://www.geeksforgeeks.org/write-regular-expressions/ Explains how to use the ^ anchor to ensure a pattern matches only if it appears at the very beginning of the string. ```Regex ^Hello ``` -------------------------------- ### Install and Use Snappytool Command-Line Utility Source: https://github.com/golang/snappy This snippet details how to install the `snappytool` command-line utility and demonstrates its basic usage for encoding and decoding data. The tool allows for direct interaction with Snappy compression from the terminal. ```Shell go install github.com/golang/snappy/cmd/snappytool@latest cat decoded | ~/go/bin/snappytool -e > encoded cat encoded | ~/go/bin/snappytool -d > decoded ``` -------------------------------- ### Compiled JavaScript for MDX Documentation Content Source: https://docs.hypermode.com/dgraph/guides This JavaScript code represents the compiled output of an MDX (Markdown/JSX) documentation page. It defines the structure of the page, including an informational alert about Dgraph documentation overhaul, and a list of navigation links to Dgraph guides such as 'Get Started', 'Graph Data Models', and 'Build a To-Do list app'. ```JavaScript "use strict"; const {Fragment: _Fragment, jsx: _jsx, jsxs: _jsxs} = arguments[0]; const {useMDXComponents: _provideComponents} = arguments[0]; function _createMdxContent(props) { const _components = { a: "a", li: "li", p: "p", ul: "ul", ..._provideComponents(), ...props.components }, {Info} = _components; if (!Info) _missingMdxReference("Info", true); return _jsxs(_Fragment, { children: [_jsx(Info, { children: _jsxs(_components.p, { children: ["We’re overhauling Dgraph’s docs to make them clearer and more approachable. If\nyou notice any issues during this transition or have suggestions, please\n", _jsx(_components.a, { href: "https://github.com/hypermodeinc/docs/issues", children: "let us know" }), "."] }) }), "\n", _jsxs(_components.ul, { children: ["\n", _jsx(_components.li, { children: _jsx(_components.a, { href: "/dgraph/guides/get-started-with-dgraph/introduction", children: "Get Started with Dgraph" }) }), "\n", _jsx(_components.li, { children: _jsx(_components.a, { href: "/dgraph/guides/graph-data-models-101", children: "Graph Data Models 101" }) }), "\n", _jsx(_components.li, { children: _jsx(_components.a, { href: "/dgraph/guides/to-do-app/introduction", children: "Build a To-Do list app" }) }), "\n", _jsx(_components.li, { children: _jsx(_components.a, { href: "/dgraph/guides/message-board-app/introduction", children: "Build a Message Board app" }) }), "\n"] }) ] }); } function MDXContent(props = {}) { const {wrapper: MDXLayout} = { ..._provideComponents(), ...props.components }; return MDXLayout ? _jsx(MDXLayout, { ...props, children: _jsx(_createMdxContent, { ...props }) }) : _createMdxContent(props); } return { default: MDXContent }; function _missingMdxReference(id, component) { throw new Error("Expected " + (component ? "component" : "object") + " `" + id + "` to be defined: you likely forgot to import, pass, or provide it."); } ``` -------------------------------- ### Kubectl Get Command Source: https://kubernetes.io/docs/tasks/tools/install-kubectl/ Display one or many resources. ```APIDOC kubectl get Description: Displays one or many resources. ``` -------------------------------- ### JavaScript Dynamic Script Loading Examples Source: https://pkg.go.dev/github.com/dgraph-io/badger/v3 Demonstrates the practical application of the `loadScript` utility. It shows how to load a third-party polyfill script without module attributes and a custom frontend script with default module attributes, illustrating flexible script inclusion. ```JavaScript loadScript("/third_party/dialog-polyfill/dialog-polyfill.js", false) loadScript("/static/frontend/frontend.js"); ``` -------------------------------- ### Install Hypermode Frontend Project Dependencies Source: https://github.com/hypermodeinc/hyper-commerce Use `pnpm` to install all necessary dependencies for the Hypermode frontend application. This step is crucial before starting the development server. ```bash pnpm install ``` -------------------------------- ### Install Go Snappy Compression Library Source: https://github.com/golang/snappy This snippet provides the command to install the `golang/snappy` package, allowing its use as a compression and decompression library within Go applications. It fetches the latest version of the library from GitHub. ```Shell go get github.com/golang/snappy ``` -------------------------------- ### Install GraphQL Playground React Component Source: https://github.com/prisma/graphql-playground Instructions for installing the graphql-playground-react package using Yarn. ```bash yarn add graphql-playground-react ``` -------------------------------- ### Execute Node.js Sample Application Source: https://github.com/hypermodeinc/dgraph-js/tree/main/examples/simple/README These commands run the sample Node.js application using either npm or yarn. The 'run' script typically executes a predefined command in the package.json file, often starting the application. ```shell npm run run or yarn run ``` -------------------------------- ### Regular Expression Start of String/Line Anchor: Caret Source: https://www.geeksforgeeks.org/write-regular-expressions/ The caret symbol `^` is an anchor that asserts the position at the beginning of the string or the beginning of a line (depending on multiline mode). ```Regular Expression ^\d{3} ``` -------------------------------- ### Install Specific Version of HashiCorp Vault Helm Chart Source: https://www.vaultproject.io/docs/platform/k8s/helm Command to list available releases and then install a specific version of the HashiCorp Vault Helm chart. The example shows how to list releases. ```sh # List the available releases $ helm search repo ``` -------------------------------- ### Install Dgraph JavaScript Client Dependencies Source: https://github.com/hypermodeinc/dgraph-js/tree/main/examples/tls Installs the required Node.js packages, including the `dgraph-js` client, from the `package.json` file. This command ensures all necessary dependencies are available to run Dgraph client examples. ```shell npm install ``` -------------------------------- ### Install Prometheus-Grafana Stack with Helm Source: https://github.com/hypermodeinc/dgraph/tree/master/contrib/config/monitoring/prometheus/chart-values This command installs the `kube-prometheus-stack` Helm chart, which includes Prometheus and Grafana, into a specified Kubernetes namespace. It requires setting the Grafana admin password and optionally defining the namespace. ```shell helm install my-prometheus \ --values ./dgraph-prometheus-operator.yaml \ --set grafana.adminPassword=$GRAFANA_ADMIN_PASSWORD \ --namespace $NAMESPACE \ prometheus-community/kube-prometheus-stack ``` -------------------------------- ### Build and Install Dgraph from Source Source: https://github.com/hypermodeinc/dgraph Instructions to clone the Dgraph repository and install the Dgraph binary using `make install`. This process places the binary in the directory specified by the GOBIN environment variable, which defaults to $GOPATH/bin or $HOME/go/bin. ```Shell git clone https://github.com/hypermodeinc/dgraph.git cd dgraph make install ``` -------------------------------- ### Install Dgraph using curl and bash Source: https://github.com/dgraph-io/Install-Dgraph This command downloads and installs Dgraph using a curl script, specifying a particular version. It's a common method for quick setup on Unix-like systems. ```bash curl https://get.dgraph.io -sSf | VERSION=v20.03.1-beta1 bash ``` -------------------------------- ### Run Dgraph Java Sample Application via Gradle Source: https://github.com/hypermodeinc/dgraph4j/tree/main/samples/DgraphJavaSample Execute the Dgraph Java sample application using Gradle. This command runs the application, which will clear existing Dgraph data and perform a sample query. A successful run is indicated by 'Alice' in the output, confirming the setup is working correctly. ```shell $ ./gradlew run > Task :run people found: 1 Alice BUILD SUCCESSFUL in 1s 2 actionable tasks: 2 executed ``` -------------------------------- ### Example Application Configuration in JSON Source: https://github.com/hashicorp/hcl This JSON snippet demonstrates a basic application configuration, defining a listening address and commands for 'main' and 'mgmt' processes. It shows how to specify process commands as arrays of strings. ```json { "listen_addr": "127.0.0.1:8080", "process": { "main": { "command": ["/usr/local/bin/awesome-app", "server"] }, "mgmt": { "command": ["/usr/local/bin/awesome-app", "mgmt"] } } } ``` -------------------------------- ### Dgraph: JSON Example for Inserting Multiple Entities Source: https://docs.hypermode.com/dgraph/guides/get-started-with-dgraph/introduction This JSON array demonstrates the structure for inserting multiple entities into a Dgraph database. Each object within the array represents an entity with various predicates (e.g., "name", "age", "country", "city"). Dgraph's flexibility allows these predicates to be created automatically if they do not already exist in the schema. ```JSON [ { "name": "Alice", "age": 30, "country": "India" }, { "name": "Daniel", "age": 25, "city": "San Diego" } ] ``` -------------------------------- ### Install Badger Command Line Tool Source: https://github.com/hypermodeinc/badger Steps to install the Badger CLI tool, which can perform operations like offline backup/restore. This involves navigating to the Badger repository and running `go install .` to place the utility in your $GOBIN path. ```shell cd badger go install . ``` -------------------------------- ### Install kube-prometheus-stack with Helm Source: https://github.com/hypermodeinc/dgraph/tree/master/contrib/config/monitoring/prometheus/chart-values This command sequence adds the necessary Helm repositories, updates them, and then performs a Helm installation of the kube-prometheus-stack. It includes placeholders for setting the Grafana administrator password and defining the target Kubernetes namespace. ```shell helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo add stable https://charts.helm.sh/stable helm repo update ## set Grafana secret admin password GRAFANA_ADMIN_PASSWORD='' ## optionally set namespace (default=monitoring if not specified) export NAMESPACE="monitoring" helm install my-prometheus \ --values ./dgraph-prometheus-operator.yaml \ --set grafana.adminPassword=$GRAFANA_ADMIN_PASSWORD \ --namespace $NAMESPACE \ prometheus-community/kube-prometheus-stack ``` -------------------------------- ### Go: Perform Basic Dgraph Schema, Mutate, and Query Operations Source: https://godoc.org/github.com/dgraph-io/dgo This Go example demonstrates how to connect to a Dgraph instance, define a schema, insert new data using N-quads, update existing data based on a query, and finally query the data. It covers initial setup, schema definition, data creation, and updates. ```Go package main import ( "context" "fmt" "log" "strings" "time" "github.com/dgraph-io/dgo" "github.com/dgraph-io/dgo/protos/api" "google.golang.org/grpc" ) type CancelFunc func() func getDgraphClient() (*dgo.Dgraph, CancelFunc) { conn, err := grpc.Dial("127.0.0.1:9180", grpc.WithInsecure()) if err != nil { log.Fatal("While trying to dial gRPC") } dc := api.NewDgraphClient(conn) dg := dgo.NewDgraphClient(dc) ctx := context.Background() for { err = dg.Login(ctx, "groot", "password") if err == nil || !strings.Contains(err.Error(), "Please retry") { break } time.Sleep(time.Second) } if err != nil { log.Fatalf("While trying to login %v", err.Error()) } return dg, func() { if err := conn.Close(); err != nil { log.Printf("Error while closing connection:%v", err) } } } func main() { dg, cancel := getDgraphClient() defer cancel() ctx, toCancel := context.WithTimeout(context.Background(), 30*time.Second) defer toCancel() // Warn: Cleaning up the database if err := dg.Alter(ctx, &api.Operation{DropAll: true}); err != nil { log.Fatal("The drop all operation should have succeeded") } op := &api.Operation{} op.Schema = "\n\t name: string .\n\t email: string @index(exact) .\n\t" if err := dg.Alter(ctx, op); err != nil { log.Fatal(err) } m1 := "\n\t _:n1 \"user\" .\n\t _:n1 \"user@dgraphO.io\" .\n" mu := &api.Mutation{ SetNquads: []byte(m1), CommitNow: true, } if _, err := dg.NewTxn().Mutate(ctx, mu); err != nil { log.Fatal(err) } mu.Query = "\n\t query {\n \t\t\tme(func: eq(email, \"user@dgraphO.io\")) {\n\t \t\tv as uid\n \t\t\t}\n\t }\n\t" m2 := "uid(v) \"user@dgraph.io\" ." mu.SetNquads = []byte(m2) // Update email only if matching uid found. if _, err := dg.NewTxn().Mutate(ctx, mu); err != nil { log.Fatal(err) } query := "\n\t {\n\t\t\tme(func: eq(email, \"user@dgraph.io\")) {\n\t\t\t\tname\n\t\t\t\temail\n\t\t\t}\n\t }\n\t" resp, err := dg.NewTxn().Query(ctx, query) if err != nil { log.Fatal(err) } // resp.Json contains the updated value. fmt.Println(string(resp.Json)) } ``` -------------------------------- ### Set Up GraphQL Playground React Development Environment Source: https://github.com/prisma-labs/graphql-playground Commands to initialize and start the local development environment for the `graphql-playground-react` package. This involves navigating to the package directory, installing dependencies with Yarn, and launching the development server for UI testing. ```Shell $ cd packages/graphql-playground-react $ yarn $ yarn start ``` -------------------------------- ### Create Dgraph Data Directories Source: https://github.com/hypermodeinc/dgraph-js/tree/main/examples/simple Creates the necessary local directories for Dgraph Zero and Dgraph Alpha data storage. This ensures a clean environment for Dgraph components. ```shell mkdir -p local-dgraph-data/zero local-dgraph-data/data ``` -------------------------------- ### Run Dgraph Ratel Docker Container Source: https://docs.hypermode.com/dgraph/guides/get-started-with-dgraph/introduction This command starts a Dgraph Ratel instance in a Docker container, mapping port 8000 to the host and running it in detached mode. It uses the latest dgraph/ratel image to provide a web-based interface for Dgraph. ```shellscript docker run --rm -d -p 8000:8000 dgraph/ratel:latest ``` -------------------------------- ### Clone and Install Dgraph from Source Source: https://github.com/hypermodeinc/dgraph Clone the Dgraph repository from GitHub, navigate into the directory, and use 'make install' to build and install the Dgraph binary. The binary will be placed in the directory specified by the GOBIN environment variable. ```shell git clone https://github.com/hypermodeinc/dgraph.git cd dgraph make install ``` -------------------------------- ### Example Shell Output for Data Query Source: https://github.com/dgraph-io/dgraph-js-http This snippet shows the expected console output from a data query operation, specifically demonstrating the count of people named 'Alice' and one of their names. It serves as an example of successful data retrieval. ```Shell Number of people named "Alice": 1 Alice ``` -------------------------------- ### Install Kube-State-Metrics Project via Go Get Source: https://github.com/kubernetes/kube-state-metrics This command demonstrates how to install the `kube-state-metrics` project into your Go workspace (`$GOPATH`). It fetches the project source code, making it available for local development or building. ```shell go get k8s.io/kube-state-metrics ``` -------------------------------- ### Install Dgraph using PowerShell Commands Source: https://github.com/dgraph-io/Install-Dgraph These commands demonstrate various ways to download and install Dgraph using the official PowerShell script, including specifying environment variables and running the script locally. ```PowerShell iwr https://get.dgraph.io/windows -useb | iex ``` ```PowerShell $Version="v22.00.1"; $acceptLicense="yes"; iwr http://get.dgraph.io/windows -useb | iex ``` ```PowerShell iwr http://get.dgraph.io/windows -useb -outf install.ps1; .\install.ps1 ``` ```PowerShell iwr http://get.dgraph.io/windows -useb -outf install.ps1; .\install.ps1 -version v22.00.1 -acceptLicense yes ``` -------------------------------- ### Feature Comparison of Key-Value Stores Source: https://github.com/hypermodeinc/badger Compares Badger, RocksDB, and BoltDB across various design and performance features, including transaction support, SSD optimization, and Go language compatibility. ```APIDOC Feature Comparison: Feature: Design Badger: LSM tree with value log RocksDB: LSM tree only BoltDB: B+ tree Feature: High Read throughput Badger: Yes RocksDB: No BoltDB: Yes Feature: High Write throughput Badger: Yes RocksDB: Yes BoltDB: No Feature: Designed for SSDs Badger: Yes (with latest research [1]) RocksDB: Not specifically [2] BoltDB: No Feature: Embeddable Badger: Yes RocksDB: Yes BoltDB: Yes Feature: Sorted KV access Badger: Yes RocksDB: Yes BoltDB: Yes Feature: Pure Go (no Cgo) Badger: Yes RocksDB: No BoltDB: Yes Feature: Transactions Badger: Yes, ACID, concurrent with SSI [3] RocksDB: Yes (but non-ACID) BoltDB: Yes, ACID Feature: Snapshots Badger: Yes RocksDB: Yes BoltDB: Yes Feature: TTL support Badger: Yes RocksDB: Yes BoltDB: No Feature: 3D access (key-value-version) Badger: Yes [4] RocksDB: No BoltDB: No Footnotes: [1] The WISCKEY paper (on which Badger is based) saw big wins with separating values from keys, significantly reducing the write amplification compared to a typical LSM tree. [2] RocksDB is an SSD optimized version of LevelDB, which was designed specifically for rotating disks. As such RocksDB's design isn't aimed at SSDs. [3] SSI: Serializable Snapshot Isolation. For more details, see the blog post Concurrent ACID Transactions in Badger (https://hypermode.com/blog/badger-txn/). [4] Badger provides direct access to value versions via its Iterator API. Users can also specify how many versions to keep per key via Options. ``` -------------------------------- ### Run Go Snappy Benchmarks with Assembly Optimizations Source: https://github.com/golang/snappy Command to execute performance benchmarks for the Go Snappy library, leveraging assembly optimizations. The output displays decompression (U) and compression (Z) speeds for various file types, indicating the library's efficiency. ```Shell go test -test.bench=. ``` -------------------------------- ### Install Dgraph Helm Chart Source: https://github.com/dgraph-io/charts/ This snippet demonstrates how to add the official Dgraph Helm repository and then deploy the Dgraph database onto a Kubernetes cluster using the `helm install` command. This provides a quick way to get Dgraph running. ```Shell $ helm repo add dgraph https://charts.dgraph.io $ helm install my-release dgraph/dgraph ``` -------------------------------- ### Install GraphQL Playground React Component Source: https://github.com/prisma-labs/graphql-playground Instructions for installing the `graphql-playground-react` package using Yarn, a package manager for JavaScript. ```bash yarn add graphql-playground-react ```