### Run Apollo Router with Rover (Shell) Source: https://github.com/takumi3488/gqlforge/blob/main/examples/federation/README.md This approach uses the Apollo Rover CLI to start the Apollo router. It requires the installation of Apollo Rover. The 'rover.sh' script is used to initiate the router. ```bash ./rover.sh ``` -------------------------------- ### Run Apollo Router with npm (JavaScript) Source: https://github.com/takumi3488/gqlforge/blob/main/examples/federation/README.md This method involves running the Apollo router using Node.js and npm. Ensure you have installed the necessary dependencies with 'npm install' before starting the router with 'npm start'. ```bash npm install npm start ``` -------------------------------- ### Start GQLForge server with configuration files Source: https://context7.com/takumi3488/gqlforge/llms.txt Demonstrates how to start the GQLForge GraphQL server using one or more configuration files. It shows examples for single file, multiple merged files, and enabling SSL verification for upstream connections. ```bash # Start with a single config file gqlforge start ./app.graphql # Start with multiple config files (merged) gqlforge start ./schema.graphql ./extensions.graphql # Start with SSL verification enabled for upstream connections gqlforge start ./app.graphql --verify-ssl ``` -------------------------------- ### Start GQLForge Server Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/getting-started.md Starts the GQLForge server using a specified schema file. The server will be accessible at http://localhost:8000, and a GraphQL Playground will be available at the same address. ```bash gqlforge start ./app.graphql ``` -------------------------------- ### Start gqlforge Subgraph Examples (Rust) Source: https://github.com/takumi3488/gqlforge/blob/main/examples/federation/README.md These commands initiate gqlforge subgraphs using Rust. They require the gqlforge executable and the specified .graphql schema files as input. ```bash cargo run -- start examples/apollo_federation_subgraph_post.graphql ``` ```bash cargo run -- start examples/apollo_federation_subgraph_user.graphql ``` -------------------------------- ### Verify GQLForge Installation Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/getting-started.md Checks if the GQLForge CLI is installed correctly by printing its version number. This command should be run after installation via Cargo or Docker. ```bash gqlforge --version ``` -------------------------------- ### Example Workflow: Generate, Check, and Start GQLForge App Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/config-generation.md Demonstrates a typical workflow for using `gqlforge gen`. First, it generates an initial configuration from an API spec and redirects the output to a file. Then, it checks the generated schema for validity. Finally, it starts the GQLForge server with the generated and customized configuration. ```bash gqlforge gen ./api-spec.json > app.graphql gqlforge check ./app.graphql gqlforge start ./app.graphql ``` -------------------------------- ### Install GQLForge using various methods Source: https://context7.com/takumi3488/gqlforge/llms.txt This section details multiple methods for installing GQLForge, including Homebrew, a shell script installer, Cargo, and Docker. It also includes a command to verify the installation. ```bash # Homebrew (macOS / Linux) brew install smartcrabai/tap/gqlforge # Shell installer curl --proto '=https' --tlsv1.2 -LsSf \ https://github.com/smartcrabai/gqlforge/releases/latest/download/gqlforge-installer.sh | sh # Cargo cargo install --git https://github.com/smartcrabai/gqlforge # Docker docker pull ghcr.io/smartcrabai/gqlforge/gqlforge docker run -p 8000:8000 -p 8081:8081 ghcr.io/smartcrabai/gqlforge/gqlforge # Verify installation gqlforge --version ``` -------------------------------- ### Install Gqlforge using Shell Script Source: https://github.com/takumi3488/gqlforge/blob/main/README.md Installs Gqlforge on macOS and Linux by downloading and executing an official installer script. This method ensures you get the latest release directly from GitHub. ```bash curl --proto '=https' --tlsv1.2 -LsSf \ https://github.com/smartcrabai/gqlforge/releases/latest/download/gqlforge-installer.sh | sh ``` -------------------------------- ### GET /users/{id} Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/with-args-url.md Fetches a user by their ID. This endpoint is exposed via a GraphQL schema that translates requests to an HTTP GET call. ```APIDOC ## GET /users/{id} ### Description Fetches a user by their unique identifier. ### Method GET ### Endpoint `/users/{id}` ### Parameters #### Path Parameters - **id** (Int!) - Required - The unique identifier of the user to retrieve. ### Request Example ```json { "query": "query { user(id: 1) { id name } }" } ``` ### Response #### Success Response (200) - **id** (Int) - The unique identifier of the user. - **name** (String) - The name of the user. #### Response Example ```json { "data": { "user": { "id": 1, "name": "foo" } } } ``` ``` -------------------------------- ### GQLForge Logging Examples Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/logging.md Provides example commands for setting log levels in GQLForge for different scenarios, including development (verbose), production (standard), and troubleshooting. ```bash # Development: verbose output RUST_LOG=debug gqlforge start config.graphql # Production: standard output RUST_LOG=info gqlforge start config.graphql # Troubleshooting upstream calls RUST_LOG="gqlforge=trace" gqlforge start config.graphql ``` -------------------------------- ### Full Apollo Federation Example Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/apollo-federation-subgraph.md This example demonstrates a complete GQLForge subgraph configuration for Apollo Federation. It includes server setup, upstream configuration, query definitions, and entity definitions for User and Post, along with an entity resolver for Post's author. ```graphql schema @server(port: 8001, enable_federation: true) @upstream(base_url: "https://api.example.com") { query: Query } type Query { users: [User] @http(url: "/users") } type User @key(fields: "id") { id: Int! name: String! email: Email } type Post @key(fields: "id") { id: Int! title: String! author: User @http(url: "/users/{{.value.authorId}}") } ``` -------------------------------- ### Install Rust Toolchain Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/contributors/guidelines.md Installs the Rust toolchain using rustup. This is a prerequisite for contributing to GQLForge. It fetches and executes the official installation script. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### Set Environment Variable and Start GQLForge Server Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/environment-variables.md Provides an example of how to set an environment variable (API_TOKEN) and then start the GQLForge server using that variable. This is a common pattern for managing secrets. ```bash API_TOKEN=your-secret-token gqlforge start ./app.graphql ``` -------------------------------- ### Test Request Example Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/js-directive.md An example of a test request to the GraphQL endpoint. ```APIDOC ## POST /graphql (Test) ### Description Example test request to the GraphQL endpoint. ### Method POST ### Endpoint http://localhost:8080/graphql ### Request Body - **query** (String) - Required - The GraphQL query string. ### Request Example ```json { "query": "query { hello { name } }" } ``` ``` -------------------------------- ### GET /foo Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/caching-collision.md Retrieves data associated with a given ID. The 'id' parameter is used to specify the unique identifier for the data to be fetched. ```APIDOC ## GET /foo ### Description Retrieves data associated with a given ID. The 'id' parameter is used to specify the unique identifier for the data to be fetched. ### Method GET ### Endpoint /foo ### Parameters #### Query Parameters - **id** (string) - Required - The unique identifier for the data. ### Request Example ```json { "example": "http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe" } ``` ### Response #### Success Response (200) - **id** (integer) - The identifier returned in the response. #### Response Example ```json { "id": 0 } ``` ``` -------------------------------- ### Install and Run GQLForge in GitHub Actions Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/gh-action.md This snippet demonstrates how to install the GQLForge binary on an Ubuntu runner and then use it to check a GraphQL configuration file. It includes steps for downloading, making executable, and moving the binary, followed by validation commands. ```yaml name: GQLForge Check on: push: branches: [main] pull_request: branches: [main] jobs: check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install GQLForge run: | curl -sSL https://github.com/gqlforge/gqlforge/releases/latest/download/gqlforge-linux-amd64 -o gqlforge chmod +x gqlforge sudo mv gqlforge /usr/local/bin/ - name: Validate configuration run: gqlforge check config.graphql - name: Check for N+1 queries run: gqlforge check --n-plus-one-queries config.graphql ``` -------------------------------- ### GraphQL Query Example Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/playground.md An example of a GraphQL query to fetch posts, including their IDs, titles, and associated user information (name and email). This demonstrates basic query structure and field selection. ```graphql { posts { id title user { name email } } } ``` -------------------------------- ### Configure Mock Server for User Data Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/modified-field.md Sets up a mock server to respond to GET requests at a specific URL with a predefined JSON body simulating user data. This is useful for testing without a live backend. ```yaml - request: method: GET url: http://jsonplaceholder.typicode.com/users/1 response: status: 200 body: id: 1 name: Leanne Graham ``` -------------------------------- ### Start Gqlforge Server Source: https://github.com/takumi3488/gqlforge/blob/main/README.md Starts the Gqlforge server with a specified GraphQL schema file. This command reads the schema and directives to configure and run the GraphQL API. ```bash gqlforge start ./jsonplaceholder.graphql ``` -------------------------------- ### GET /foo Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/caching-collision.md Retrieves a resource based on the provided ID. This endpoint is used to fetch specific data entries identified by a unique query parameter. ```APIDOC ## GET /foo ### Description Retrieves a resource based on the provided ID. This endpoint is used to fetch specific data entries identified by a unique query parameter. ### Method GET ### Endpoint /foo ### Parameters #### Query Parameters - **id** (string) - Required - The unique identifier for the resource to be retrieved. ### Request Example ```json { "example": "GET /foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe" } ``` ### Response #### Success Response (200) - **id** (integer) - The identifier of the retrieved resource. #### Response Example ```json { "id": 14 } ``` ``` -------------------------------- ### GET /foo Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/caching-collision.md This endpoint retrieves data based on an ID. It accepts a query parameter 'id' to specify the resource. ```APIDOC ## GET /foo ### Description Retrieves data associated with a specific ID. ### Method GET ### Endpoint `/foo` ### Parameters #### Query Parameters - **id** (string) - Required - The unique identifier for the resource. ### Request Example ``` GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDHIwHe ``` ### Response #### Success Response (200) - **id** (integer) - The identifier of the retrieved resource. #### Response Example ```json { "id": 84 } ``` ``` -------------------------------- ### GET /foo Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/caching-collision.md Retrieves an item by its ID. This endpoint accepts a unique identifier as a query parameter and returns the corresponding item's details. ```APIDOC ## GET /foo ### Description Retrieves an item by its ID. This endpoint accepts a unique identifier as a query parameter and returns the corresponding item's details. ### Method GET ### Endpoint /foo ### Parameters #### Query Parameters - **id** (string) - Required - The unique identifier of the item to retrieve. ### Request Example ```json { "example": "GET /foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImR33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe" } ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the retrieved item. #### Response Example ```json { "example": { "id": 38 } } ``` ``` -------------------------------- ### GQLForge Configuration (YAML) Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/test-multiple-config-types.md Defines the structure for GQLForge configurations, specifying links to other configuration or schema files. This example links to a 'types.graphql' file. ```yaml links: - id: types type: Config src: types.graphql ``` -------------------------------- ### Install and Run Gqlforge using Docker Source: https://github.com/takumi3488/gqlforge/blob/main/README.md Installs Gqlforge using Docker by pulling the official image from GitHub Container Registry. It also demonstrates how to run the Gqlforge container, exposing the necessary ports for the GraphQL server. ```bash docker pull ghcr.io/smartcrabai/gqlforge/gqlforge docker run -p 8000:8000 -p 8081:8081 ghcr.io/smartcrabai/gqlforge/gqlforge ``` -------------------------------- ### Start GQLForge Server Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/cli.md Starts the GQLForge GraphQL server using specified configuration files. It accepts one or more file paths and supports an option to enable strict SSL certificate verification for upstream connections. ```bash gqlforge start [options] # Examples: # Start with a single config file gqlforge start ./app.graphql # Start with multiple config files gqlforge start ./schema.graphql ./extensions.graphql # Start with SSL verification enabled gqlforge start ./app.graphql --verify-ssl ``` -------------------------------- ### Supergraph Query Example (GraphQL) Source: https://github.com/takumi3488/gqlforge/blob/main/examples/federation/README.md This is an example of a supergraph query that can be executed against the Apollo router. It demonstrates fetching posts and their associated user information. ```graphql { posts { id title user { id name } } } ``` -------------------------------- ### Full Telemetry Configuration Example Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/telemetry.md A comprehensive example demonstrating how to configure the GQLForge server with multiple telemetry exporters, including OTLP for sending data to a collector and Prometheus for exposing metrics. It also includes capturing request headers. ```graphql schema @server(port: 8000) @telemetry( export: { otlp: { url: "http://localhost:4317" } prometheus: { path: "/metrics" } } request_headers: ["x-request-id"] ) { query: Query } ``` -------------------------------- ### Fetch data by ID using GET request Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/caching-collision.md Demonstrates how to fetch data by providing a unique identifier in the URL's query parameters. This endpoint is designed to return a JSON object with an 'id' field. ```http GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBZh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 0 } ``` ```http GET http://example.com/foo?id=ByVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 1 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SE3mXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 2 } ``` ```http GET http://example.com/foo?id=BEVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 3 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DFPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 4 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSoYIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 5 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKTxZigeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 6 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEomXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 7 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKFxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 8 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 9 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jsz1qh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 10 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 11 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQmYftglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 12 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqh8SEjmXWIQ7YUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 13 } ``` ```http GET http://example.com/foo?id=BVVLvrvaKTxZdgeFvbPbckXSorIxBUh4Jszyqp8SEjmXWIQmYUtglFnoImL33F5FYO25TXzQ3f7Zamx1sf3V2zFwdi4DNPDXIwHe HTTP/1.1 200 OK Content-Type: application/json { "id": 14 } ``` -------------------------------- ### Htpasswd File Content Example Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/auth-validations.md This is an example of the content found in an htpasswd file used for authentication. It lists usernames and their corresponding hashed passwords. ```text testuser1:$apr1$e3dp9qh2$fFIfHU9bilvVZBl8TxKzL/ testuser2:$2y$10$wJ/mZDURcAOBIrswCAKFsO0Nk7BpHmWl/XuhF7lNm3gBAFH3ofsuu ``` -------------------------------- ### Install Gqlforge using Homebrew Source: https://github.com/takumi3488/gqlforge/blob/main/README.md Installs Gqlforge on macOS and Linux systems using the Homebrew package manager. This is a convenient way to manage the tool's installation and updates. ```bash brew install smartcrabai/tap/gqlforge ``` -------------------------------- ### Production Client Tuning Example - GraphQL Schema Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/client-tuning.md A comprehensive example demonstrating a production-tuned configuration for the GQLForge HTTP client, combining connection pool, timeout, keep-alive, HTTP/2, and HTTP caching settings. ```graphql schema @server(port: 8000) @upstream( pool_size: 128 pool_max_idle_per_host: 32 connect_timeout: 5 timeout: 30 keep_alive_interval: 30 keep_alive_timeout: 60 keep_alive_while_idle: true http2_only: true http_cache: true ) { query: Query } ``` -------------------------------- ### Start GQLForge Server with Environment-Specific Upstream URL Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/environment-variables.md Demonstrates starting the GQLForge server with different upstream URLs set via environment variables for development and production environments. ```bash # Development UPSTREAM_URL=http://localhost:3000 gqlforge start ./app.graphql # Production UPSTREAM_URL=https://api.example.com gqlforge start ./app.graphql ``` -------------------------------- ### GraphQL Query Test Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/test-set-cookie-headers.md Example of a test case using POST to the GraphQL endpoint to execute multiple user queries. ```APIDOC ## Test GraphQL Queries ### Description This test case demonstrates how to send a POST request to the GraphQL endpoint (`http://localhost:8080/graphql`) to execute multiple user queries concurrently. It fetches the names of users with IDs 1 and 2. ### Method POST ### Endpoint `http://localhost:8080/graphql` ### Parameters #### Request Body - **query** (String!) - Required - The GraphQL query string. ### Request Example ```yaml - method: POST url: http://localhost:8080/graphql body: query: "query { u1:user(id: 1) { name } u2:user(id: 2) { name } }" ``` ### Response #### Success Response (200) - **data** (Object) - Contains the results of the queries. - **u1** (Object) - Result for the first user query. - **name** (String!) - The name of the first user. - **u2** (Object) - Result for the second user query. - **name** (String!) - The name of the second user. #### Response Example ```json { "data": { "u1": { "name": "Leanne Graham" }, "u2": { "name": "Ervin Howell" } } } ``` ``` -------------------------------- ### Install Gqlforge using Cargo Source: https://github.com/takumi3488/gqlforge/blob/main/README.md Installs Gqlforge directly from its source repository using the Cargo package manager. This is useful for developers who want to build from source or contribute to the project. ```bash cargo install --git https://github.com/smartcrabai/gqlforge ``` -------------------------------- ### Full Schema Example with gRPC Integration Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/grpc.md An example demonstrating a complete GQLForge schema that links a Protobuf file and exposes a gRPC service method as a GraphQL query. GQLForge automatically generates the corresponding GraphQL types from the Protobuf definition. ```graphql schema @server(port: 8000) @link(type: Protobuf, src: "./user.proto") { query: Query } type Query { user(id: Int!): User @grpc( service: "users.UserService" method: "GetUser" url: "https://localhost:50051" body: "{ id: {{.args.id}} }" ) } ``` -------------------------------- ### Initialize a new GQLForge project Source: https://context7.com/takumi3488/gqlforge/llms.txt Shows how to use the `gqlforge init` command to create a new GQLForge project. It includes examples for initializing in the current directory and in a new, specified directory. ```bash # Initialize in current directory gqlforge init # Initialize in a new directory gqlforge init ./my-api ``` -------------------------------- ### Initialize GQLForge Project Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/cli.md Creates a new GQLForge project, including a starter configuration file. The command can optionally take a folder path to specify the directory where the project will be created; it defaults to the current directory if no path is provided. ```bash gqlforge init [folder_path] # Examples: # Initialize in the current directory gqlforge init # Initialize in a new directory gqlforge init ./my-api ``` -------------------------------- ### Query GQLForge API with cURL Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/getting-started.md Sends a GraphQL query to the running GQLForge server using cURL. This example fetches post titles and the names of their authors, demonstrating GQLForge's ability to batch requests. ```bash curl -X POST http://localhost:8000/graphql \ -H "Content-Type: application/json" \ -d '{"query": "{ posts { title user { name } } }"}' ``` -------------------------------- ### Get User API Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/nested-recursive-types.md Retrieves a user by ID. This endpoint is part of the GraphQL schema and is exposed via an HTTP GET request. ```APIDOC ## GET /graphql ### Description Retrieves a user, including their connections, which can be recursively nested. ### Method GET ### Endpoint /graphql ### Query Parameters - **query** (String) - Required - The GraphQL query string. ### Request Example ```graphql query { user { name id connections { type nested { user { name id connections { nested { user { name id } } } } } } } } ``` ### Response #### Success Response (200) - **data** (Object) - The response data containing the user information. - **user** (Object) - User details. - **name** (String) - The name of the user. - **id** (Int) - The unique identifier of the user. - **connections** (Array) - A list of user's connections. - **type** (String) - The type of connection. - **nested** (Object) - Nested user information. - **user** (Object) - The nested user details. - **name** (String) - The name of the nested user. - **id** (Int) - The unique identifier of the nested user. - **connections** (Array) - Connections of the nested user (can be recursive). #### Response Example ```json { "data": { "user": { "name": "User1", "id": 1, "connections": [ { "type": "friend", "nested": { "user": { "name": "User2", "id": 2, "connections": [ { "nested": { "user": { "name": "User3", "id": 3 } } }, { "nested": { "user": { "name": "User4", "id": 4 } } } ] } } } ] } } } ``` ``` -------------------------------- ### GraphQL Type Definitions (File) Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/test-multiple-config-types.md Defines the input and output types for the GraphQL schema. This file specifies the structure for the 'Input' and 'Output' types used in queries. ```graphql input Input { id: Int name: String } type Output { id: Int name: String } ``` -------------------------------- ### Validate GQLForge Schema Configuration Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/getting-started.md Checks the GQLForge schema file for errors and potential issues like N+1 query problems without starting the server. This is a crucial step for validating configurations before deployment. ```bash gqlforge check ./app.graphql ``` -------------------------------- ### Configuration File - gqlforge Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/test-js-multiple-scripts.md A YAML configuration file for gqlforge, specifying upstream request handlers and linking script files. It defines how requests are routed and processed. ```yaml upstream: onRequest: "onRequest" links: - type: Script src: "test1.js" - type: Script src: "test2.js" ``` -------------------------------- ### Mock GET Request for Company Data Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/test-null-in-object.md Configures a mock response for a GET request to the /hi endpoint. This mock is used during development or testing to simulate API responses without a live backend. ```yml - request: method: GET url: http://localhost:3000/hi response: status: 200 ``` -------------------------------- ### Mock Server Configuration Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/batching.md Configures the mock server with request matching and expected response. ```APIDOC ## Mock Server ### Description Configures a mock server to intercept GET requests to a specific URL and return a predefined response. It also specifies the expected number of hits for this mock. ### Method GET ### Endpoint `http://jsonplaceholder.typicode.com/users/1` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```yaml - request: method: GET url: http://jsonplaceholder.typicode.com/users/1 headers: test: test expectedHits: 3 response: status: 200 body: id: 1 name: foo ``` ### Response #### Success Response (200) - **id** (Int) - The user's ID. - **name** (String) - The user's name. #### Response Example ```json { "id": 1, "name": "foo" } ``` ``` -------------------------------- ### Query: Get User Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/recursive-types.md Retrieves a user's information. This endpoint fetches data from `http://jsonplaceholder.typicode.com/users/1`. ```APIDOC ## GET /graphql ### Description Retrieves a user's information. ### Method GET ### Endpoint /graphql ### Query Parameters - **query** (String) - Required - The GraphQL query string. ### Request Example ```json { "query": "{\n user {\n name\n id\n connections {\n type\n user {\n name\n id\n }\n }\n }\n}" } ``` ### Response #### Success Response (200) - **data** (Object) - Contains the query result. - **user** (Object) - User details. - **name** (String) - The name of the user. - **id** (Int) - The ID of the user. - **connections** (Array) - A list of the user's connections. - **type** (String) - The type of connection. - **user** (Object) - The connected user's details. - **name** (String) - The name of the connected user. - **id** (Int) - The ID of the connected user. #### Response Example ```json { "data": { "user": { "name": "User1", "id": 1, "connections": [ { "type": "friend", "user": { "name": "User2", "id": 2 } } ] } } } ``` ``` -------------------------------- ### Mock Server Configuration Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/js-directive.md Configuration for a mock server that simulates responses for specific HTTP requests, useful for testing. ```APIDOC ## Mock Server Configuration ### Description This configuration defines mock responses for the mock server. ### Method GET ### Endpoint http://jsonplaceholder.typicode.com/users/1 ### Response #### Success Response (200) - **id** (Int) - The user ID. - **name** (String) - The user's name. ### Response Example ```json { "id": 1, "name": "Leanne Graham" } ``` ``` -------------------------------- ### GET /user/{id} Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/rest-api-error.md Retrieves user information based on the provided user ID. ```APIDOC ## GET /user/{id} ### Description Retrieves user information based on the provided user ID. ### Method GET ### Endpoint /user/{id} ### Parameters #### Path Parameters - **id** (Int) - Required - The unique identifier of the user. ### Request Example ```json { "example": "No request body for GET request" } ``` ### Response #### Success Response (200) - **id** (Int) - The unique identifier of the user. - **name** (String) - The name of the user. #### Response Example ```json { "id": 1, "name": "Leanne Graham" } ``` ``` -------------------------------- ### Mock Server Configuration for User Data Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/simple-query.md Configures a mock server to respond to requests for user data. This allows for testing the GraphQL API without relying on the actual external HTTP endpoint. It specifies the request URL and the mock response body. ```yaml - request: method: GET url: http://jsonplaceholder.typicode.com/users/1 response: status: 200 body: id: 1 name: foo ``` -------------------------------- ### Mock HTTP Responses for GraphQL Endpoint Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/upstream-fail-request-with-body.md Configures mock responses for the GraphQL endpoint. This example sets up a mock for a GET request to 'http://jsonplaceholder.typicode.com/users/1' to return a 429 status code with a specific error body, simulating an exceeded limit. ```yaml - request: method: GET url: http://jsonplaceholder.typicode.com/users/1 response: status: 429 body: { code: "UM0018", message: "change limit exceeded", cause: "exceeded the maximum allowed number of name changes" } ``` -------------------------------- ### Full Example: Query and Mutation Endpoints Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/rest.md Demonstrates defining multiple REST endpoints (GET for users and user by ID, DELETE for user) alongside a GraphQL schema. ```APIDOC ## GET /api/users ### Description Retrieves a list of all users. ### Method GET ### Endpoint /api/users ### Parameters (No parameters for this endpoint) ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **users** (Array of User) - A list of user objects. #### Response Example ```json [ { "id": 1, "name": "Alice" }, { "id": 2, "name": "Bob" } ] ``` ## GET /api/users/:id ### Description Retrieves a specific user by their ID. ### Method GET ### Endpoint /api/users/:id ### Parameters #### Path Parameters - **id** (Int!) - Required - The unique identifier for the user. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **User** (Object) - The user object. #### Response Example ```json { "id": 1, "name": "Alice" } ``` ## DELETE /api/users/:id ### Description Deletes a user by their ID. ### Method DELETE ### Endpoint /api/users/:id ### Parameters #### Path Parameters - **id** (Int!) - Required - The unique identifier for the user to delete. ### Request Example (No request body for DELETE requests) ### Response #### Success Response (200) - **Boolean** - True if the user was deleted successfully, false otherwise. #### Response Example ```json true ``` ``` -------------------------------- ### GraphQL Batch Requests Configuration Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/batching.md This section details the configuration for enabling batched GraphQL requests. ```APIDOC ## Server Configuration ### Description Enables batched requests for the GraphQL server. ### Method N/A (Configuration) ### Endpoint N/A (Configuration) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```yaml server: batchRequests: true ``` ### Response #### Success Response (200) N/A (Configuration) #### Response Example N/A (Configuration) ``` -------------------------------- ### Set Log Level with RUST_LOG Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/logging.md Configure the overall verbosity of GQLForge logs by setting the RUST_LOG environment variable. This example demonstrates setting the log level to 'info' before starting the application. ```bash RUST_LOG=info gqlforge start config.graphql ``` -------------------------------- ### GraphQL Query: Protected Scalar Source: https://github.com/takumi3488/gqlforge/blob/main/tests/execution/auth-jwt.md This endpoint allows you to query a 'protectedScalar' field using a GET request with query parameters. It includes an example of the request and expected success response. ```APIDOC ## POST /graphql ### Description This endpoint allows you to query a 'protectedScalar' field using a POST request with a query body. It includes an example of the request and expected success response. ### Method POST ### Endpoint /graphql ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. #### Request Body - **query** (string) - Required - The GraphQL query. ### Request Example ```json { "query": "query {\n protectedScalar\n}" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the result of the query. - **protectedScalar** (string) - The value of the protected scalar field. #### Response Example ```json { "data": { "protectedScalar": "exampleScalarValue" } } ``` ``` -------------------------------- ### Connect to MinIO S3-compatible service Source: https://github.com/takumi3488/gqlforge/blob/main/docs/content/docs/s3.md This example demonstrates connecting to a MinIO S3-compatible service using the @link directive. It specifies the source URL, region, and importantly, sets `forcePathStyle` to true, which is required for MinIO. ```graphql schema @link(id: "minio", type: S3, src: "http://localhost:9000", meta: { region: "us-east-1", forcePathStyle: true }) { query: Query } ``` -------------------------------- ### User Query API Source: https://github.com/takumi3488/gqlforge/blob/main/tests/postgres/postgres-single-connection.md Retrieves a list of all users from the database. ```APIDOC ## GET /graphql ### Description Retrieves a list of all users. ### Method GET ### Endpoint /graphql ### Parameters #### Query Parameters - **query** (String) - Required - The GraphQL query string. ### Request Example ```json { "query": "{\n users {\n id\n name\n email\n }\n}" } ``` ### Response #### Success Response (200) - **data** (Object) - Contains the query results. - **users** (Array) - A list of user objects. - **id** (Int) - The unique identifier for the user. - **name** (String) - The name of the user. - **email** (String) - The email address of the user. #### Response Example ```json { "data": { "users": [ { "id": 1, "name": "Alice", "email": "alice@example.com" }, { "id": 2, "name": "Bob", "email": "bob@example.com" } ] } } ``` ``` -------------------------------- ### Configure gqlforge SQL Data Source Source: https://github.com/takumi3488/gqlforge/blob/main/tests/postgres/postgres-numeric-bigint.md This YAML configuration snippet sets up a data source link for gqlforge. It specifies a link named 'main' of type 'Sql' that sources its schema definition from the 'metrics.sql' file. ```yaml links: - id: "main" type: Sql src: "metrics.sql" ```