Use the CLI to:
To install using Homebrew, run:
brew tap fragment-dev/tap &&\
brew install fragment-dev/tap/fragment-cli
Authenticate with FRAGMENT.
Authentication is scoped to one FRAGMENT Workspace. If you want to authenticate with another Workspace, you must create another API Client and follow the authentication flow again.
Credentials will be written to ~/.fragment/auth.json
.
fragment login \
[--api-url=<api-url>] \
[--client-id=<client-id>] \
[--client-secret=<client-secret>] \
[--oauth-scope=<oauth-scope>] \
[--oauth-url=<oauth-url>] \
[--test]
Optionally, run fragment login
and the CLI will prompt you for the credentials.
--api-url=<api-url> | The API URL for your FRAGMENT Workspace |
--client-id=<client-id> | The API Client ID |
--client-secret=<client-secret> | The API Client Secret |
--oauth-scope=<oauth-scope> | The OAuth Scope for your auth token |
--oauth-url=<oauth-url> | The OAuth URL from which to retrieve the auth token |
--test | If set, tests stored credentials |
fragment login \
--api-url="<api-url>" \
--client-id="<client-id>" \
--client-secret="<client-secret>" \
--oauth-scope="<oauth-scope>" \
--oauth-url="<oauth-url>"
To test the stored credentials, run:
fragment login --test
Store a Schema within your FRAGMENT workspace.
Usagefragment store-schema [-p <value>] [-v]
-p, --path=<value> | [default: fragment.jsonc] Path for schema JSON file. |
-v, --verbose | Enable verbose mode (prints GraphQL commands) |
fragment store-schema \
-p your-fragment-schema.jsonc
Create a Ledger within your FRAGMENT workspace.
Usagefragment create-ledger \
--ik=<ledger-ik> \
--name=<ledger-name> \
--schema=<schema-file>
-i, --ik=<ledger-ik> | Idempotency key for createLedger |
-n, --name=<ledger-name> | Ledger name |
-s, --schema=<schema-key> | [default: fragment.jsonc] Path to the schema JSON file. |
-v, --verbose | Enable verbose mode (prints GraphQL commands) |
fragment create-ledger \
--ik=test-ledger \
--name="Test Ledger" \
--schema=your-fragment-schema.jsonc
Retrieve a Schema from the API for local use.
Usagefragment get-schema \
[--key=<schema-key>] \
[--version=<version>] \
[--output=<output-file>] \
[-v]
-k, --key=<schema-key> | (Optional) Key of the Schema (e.g. template-schema). If not provided, you'll be prompted to choose a Schema. |
-o, --output=<output-file> | Path to the JSONC schema file. Defaults to the schema key in the current directory. |
--version=<version> | Schema version to retrieve. Defaults to the latest version. |
-v, --verbose | Enable verbose mode (prints GraphQL commands) |
To choose the Schema from a list, run:
fragment get-schema
If providing the Schema key, run:
fragment get-schema \
--key=test-schema
Post a Ledger Entry to your FRAGMENT Ledger.
Usagefragment add-ledger-entry \
--ik=<add-ledger-entry-ik> \
--ledger.ik=<ledger-ik> \
--type=<entry-type> \
[--param=<parameter-value>] \
[-v]
-i, --ik=<add-ledger-entry-ik> | Idempotency key for addLedgerEntry |
-l, --ledger.ik=<ledger-ik> | Idempotency Key of the Ledger to post the Ledger Entry to |
-t, --type=<entry-type> | The type of Ledger Entry you want to post |
-p, --param=<value>... | The parameters for your Ledger Entry. You may specify multiple parameters by repeating the flag. (ex: --param amount=100 --param currency=USD) |
-v, --verbose | Enable verbose mode (prints GraphQL commands) |
fragment add-ledger-entry \
--ik=your-entry-ik \
--ledger.ik=your-ledger-ik \
--type=user_funds_account \
--param='user_id="testing-user"' \
--param='funding_amount="200"'
Create a Custom Link.
Usagefragment create-custom-link \
--ik=<custom-link-ik> \
--name=<custom-link-name>
-i, --ik=<custom-link-ik> | The Idempotency Key for Custom Link creation |
--name=<custom-link-name> | The name for the Custom Link |
fragment create-custom-link \
--ik="example-custom-link" \
--name="Example Custom Link"
Generate GraphQL queries to post Ledger Entries for a given Schema.
The generated GraphQL queries can be used to generate SDK code specific to your Schema. Read Install the SDK to learn more.
Usagefragment gen-graphql \
--path=<path-to-schema.jsonc> \
--output=<output-filename.graphql>
-o, --output=<output-filename> | The path for the generated file. Must end with .graphql or .gql |
-p, --path=<schema-file-path> | The path to your Schema file |
--output-file-per-query | Output a folder of queries, instead of a single file |
--include-standard-queries | Include the set of standard GraphQL queries in the output. This is required only if you are not using the FRAGMENT SDKs |
fragment gen-graphql \
--path=your-fragment-schema.jsonc \
--output=queries.graphql
fragment gen-graphql \
--path=your-fragment-schema.jsonc \
--output=generated/queries \
--output-file-per-query
Update the FRAGMENT CLI.
Usagefragment update [-y] [--dry-run]
-y, --yes | Update without being prompted |
--dry-run | Run the update process without updating the CLI |
fragment update -y
Get a FRAGMENT Authentication Token.
This will print your auth token to standard output (stdout).
Usagefragment token
Display help prompt for the CLI.
Usagefragment help [COMMANDS]
COMMANDS... | The Command (or Commands) to show help for. Ex: store-schema |
fragment help store-schema
Get the details of the Workspace this CLI is authenticated to.
Usagefragment workspace