-
-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): reorg graphql example so pub displays code
- Loading branch information
Showing
8 changed files
with
123 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
# `graphql` Example Application | ||
# `graphql/client.dart` Example Application | ||
|
||
This is a simple command line application to showcase how you can use the Dart GraphQL Client, without flutter. | ||
This is a simple command line application to showcase how you can use the Dart GraphQL Client, without flutter. | ||
|
||
To run this application: | ||
|
||
## Setup: | ||
|
||
1. First clone this repository and navigate to this directory | ||
2. Install all dart dependencies | ||
4. create a file `bin/local.dart` with the content: | ||
3. create a file `bin/local.dart` with the content: | ||
```dart | ||
const String YOUR_PERSONAL_ACCESS_TOKEN = | ||
'<YOUR_PERSONAL_ACCESS_TOKEN>'; | ||
``` | ||
3. Then run the Application using the commands below: | ||
|
||
1. **List Your Repositories** | ||
|
||
``` | ||
pub run main.dart | ||
``` | ||
|
||
2. **Star Repository** | ||
## Usage: | ||
|
||
``` | ||
pub run main.dart -a star --id <REPOSITORY_ID_HERE> | ||
``` | ||
```sh | ||
# List repositories | ||
pub run example | ||
|
||
3. **Unstar Repository** | ||
# Star Repository (you can get repository ids from `pub run example`) | ||
pub run example -a star --id $REPOSITORY_ID | ||
|
||
``` | ||
pub run main.dart -a unstar --id <REPOSITORY_ID_HERE> | ||
``` | ||
# Unstar Repository | ||
pub run example -a unstar --id $REPOSITORY_ID | ||
``` | ||
|
||
**NB:** Replace repository id in the last two commands with a real Github Repository ID. You can get by running the first command, IDs are printed on the console. | ||
**NB:** Replace repository id in the last two commands with a real Github Repository ID. You can get by running the first command, IDs are printed on the console. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:args/args.dart'; | ||
import 'package:example/main.dart'; | ||
|
||
ArgResults argResults; | ||
|
||
/// CLI fro executing github actions | ||
/// | ||
/// Usage: | ||
/// ```sh | ||
/// # List repositories | ||
/// pub run example | ||
/// | ||
/// # Star Repository | ||
/// pub run example -a star --id $REPOSITORY_ID_HERE | ||
/// | ||
/// # Unstar Repository | ||
/// pub run example -a unstar --id $REPOSITORY_ID_HERE | ||
/// ``` | ||
void main(List<String> arguments) { | ||
final ArgParser parser = ArgParser() | ||
..addOption('action', abbr: 'a', defaultsTo: 'fetch') | ||
..addOption('id', defaultsTo: ''); | ||
|
||
argResults = parser.parse(arguments); | ||
|
||
final String action = argResults['action'] as String; | ||
final String id = argResults['id'] as String; | ||
|
||
switch (action) { | ||
case 'star': | ||
starRepository(id); | ||
break; | ||
case 'unstar': | ||
removeStarFromRepository(id); | ||
break; | ||
default: | ||
readRepositories(); | ||
break; | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
packages/graphql/example/bin/graphql_operation/mutations/addStar.dart
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
packages/graphql/example/bin/graphql_operation/mutations/mutations.dart
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
packages/graphql/example/bin/graphql_operation/mutations/removeStar.dart
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
packages/graphql/example/bin/graphql_operation/queries/readRepositories.dart
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ dependencies: | |
args: | ||
graphql: | ||
path: .. | ||
|
||
executables: | ||
example: example |