Skip to content

Commit ff5ffa9

Browse files
authored
added Supported GraphQL client code combinations
1 parent 3426fff commit ff5ffa9

File tree

1 file changed

+13
-24
lines changed
  • src/pages/gen2/reference/cli-commands

1 file changed

+13
-24
lines changed

src/pages/gen2/reference/cli-commands/index.mdx

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -224,23 +224,20 @@ The available parameters for `npx amplify generate graphql-client-code` are:
224224
Required parameters:
225225
- Stack identifier
226226
- `--stack`: A stack name that contains an Amplify backend.
227-
- XOR
228227
- Project identifier
229228
- `--app-id`(String) - The Amplify App ID of the project.
230229
- `--branch`(String) - A git branch of the Amplify project.
231230

232231
Optional parameters:
233-
- `--debug` (boolean) - Print debug logs to the console.
234-
- `--debug`(boolean) - Enables printing debug logs to the console.
235-
- `--help`(boolean) - Displays help information about the command.
236-
- `--profile`(string) - Specifies an AWS profile name.
237232
- `--out`(string) - Specifies the path to the directory where the config is written. If not provided, defaults to the current process working directory.
238233
- `--format`(string (choices: "modelgen", "graphql-codegen", "introspection")) - Specifies the format of the GraphQL client code to be generated.
239234
- `--model-target` (string (choices: "java", "swift", "javascript", "typescript", "dart")) - Specifies the modelgen export target. Only applies when the --format parameter is set to modelgen.
240235
- `--statement-target`(string (choices: "javascript", "graphql", "flow", "typescript", "angular")) - Specifies the graphql-codegen statement export target. Only applies when the --format parameter is set to graphql-codegen.
241236
- `--type-target`(string (choices: "json", "swift", "typescript", "flow", "scala", "flow-modern", "angular")) - Specifies the optional graphql-codegen type export target. Only applies when the --format parameter is set to graphql-codegen.
242237
- `--all`(boolean)- Shows hidden options.
243-
238+
- `--profile`(string) - Specifies an AWS profile name.
239+
- `--debug` (boolean) - Print debug logs to the console.
240+
- `--help`(boolean) - Displays help information about the command.
244241
<SubCommandHeading parentCommand="amplify-graphql-client-code">Usage</SubCommandHeading>
245242

246243

@@ -276,32 +273,24 @@ npx cdk deploy
276273
```
277274
Run Amplify codegen command to generate GraphQL codegen:
278275
```bash
279-
npx amplify generate graphql-client-code --stack="my-amplify-stack" --platform ts --out ./src
276+
npx amplify generate graphql-client-code --stack="my-amplify-backend" --platform ts --out ./src
280277
```
281278
### Generate codegen in specfic language and format
282279

283280
```bash
284281
npx amplify generate graphql-client-code --format modelgen --type-target angular
285282
```
286283
### Supported GraphQL client code combinations:
287-
How to find the right format for your GraphQL client code:
288-
289-
- What platform are you building your app for?
290-
- TypeScript
291-
- Do you have conflict resolution enabled on your API?
292-
- No: "Introspection schema".
293-
- If you need backwards-compatibility with Amplify (Classic) codebases, then you can generate "GraphQL codegen" in addition to the introspection schema.
294-
- Yes: "Modelgen". Only use with DataStore.
295-
- Android
296-
- Which library are you using?
297-
- AWS Amplify: "Modelgen"
298-
- AWS Mobile SDK: "GraphQL codegen"
299-
- Swift
300-
- Which library are you using?
301-
- AWS Amplify: "Modelgen"
302-
- AWS Mobile SDK: "GraphQL codegen"
303284

304-
{/* @TODO */}
285+
| Format | Platform | Codegen command in Amplify CLI | Command in Amplify Gen2 | Default generated file/path |
286+
| -------| -------- | ------------------------------ | ----------------------- | --------------------------- |
287+
| Introspection schema | Amplify Javascript | N/A | `npx amplify generate graphql-client-code --format introspection` | <path_to_app>/ |
288+
| GraphQL codegen | Amplify Javascript | `amplify codegen` | `npx amplify generate graphql-client-code -format graphql-codegen --statement-target javascript --out <path_to_app>/src/graphql/` | `<path_to_app>/src/graphql/` \
289+
| Modelgen | Amplify Javascript | `amplify codegen model` | `npx amplify generate graphql-client-code --format modelgen --model-target javascript --out <path_to_app>/src/models/` | `<path_to_app>/src/models/` \
290+
| Modelgen | Amplify Android | `amplify codegen model` | `npx amplify generate graphql-client-code --format modelgen --model-target java --out <path_to_app/src/main/java/>` | `<path_to_app>/src/main/java/com/amplifyframework/datastore/generated/model` |
291+
| Modelgen | Amplify Swift | `amplify codegen model` | `npx amplify generate graphql-client-code --format modelgen --model-target swift --out <path_to_swift_project>/AmplifyModels` | `<path_to_swift_project>/AmplifyModels` |
292+
| Modelgen | Amplify Flutter | `amplify codegen model` | `npx amplify generate graphql-client-code --format modelgen --model-target dart --out <path_to_flutter_project>/AmplifyModels` | `<path_to_flutter_project>/AmplifyModels` |
293+
305294

306295
## npx amplify generate forms
307296

0 commit comments

Comments
 (0)