Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate client code command #265

Merged
merged 11 commits into from
Sep 25, 2023
Merged

generate client code command #265

merged 11 commits into from
Sep 25, 2023

Conversation

alharris-at
Copy link
Contributor

@alharris-at alharris-at commented Sep 21, 2023

Issue #, if available:
N/A

Description of changes:
Add the generate graphql-client-code command to the CLI.

Help Output:

➜  samsara-cli git:(generate-client-code-command) ✗ amplify generate graphql-client-code --help
amplify generate graphql-client-code

Generates graphql API code

Stack identifier
  --stack  A stack name that contains an Amplify backend                [string]

Project identifier
  --appId   The Amplify App ID of the project                           [string]
  --branch  A git branch of the Amplify project                         [string]

Options:
  --version          Show version number                               [boolean]
  --help             Show help                                         [boolean]
  --out              A path to directory where config is written. If not provide
                     d defaults to current process working directory.   [string]
  --format           The format that the GraphQL client code should be generated
                      in.
              [string] [choices: "graphql-codegen", "introspection", "modelgen"]
  --modelTarget      The modelgen export target. Only applies when the `--format
                     ` parameter is set to `modelgen`
         [string] [choices: "java", "swift", "javascript", "typescript", "dart"]
  --statementTarget  The graphql-codegen statement export target. Only applies w
                     hen the `--format` parameter is set to `graphql-codegen`
    [string] [choices: "javascript", "graphql", "flow", "typescript", "angular"]
  --typeTarget       The optional graphql-codegen type export target. Only appli
                     es when the `--format` parameter is set to `graphql-codegen
                     `
  [string] [choices: "json", "swift", "ts", "typescript", "flow", "scala", "flow
                                                            -modern", "angular"]
  --all              Show hidden options                               [boolean]

Extended Help Output (including all feature flags):

➜  samsara-cli git:(generate-client-code-command) ✗ amplify generate graphql-client-code --help --all
amplify generate graphql-client-code

Generates graphql API code

Stack identifier
  --stack  A stack name that contains an Amplify backend                [string]

Project identifier
  --appId   The Amplify App ID of the project                           [string]
  --branch  A git branch of the Amplify project                         [string]

Options:
  --version                                 Show version number        [boolean]
  --help                                    Show help                  [boolean]
  --out                                     A path to directory where config is
                                            written. If not provided defaults to
                                             current process working directory.
                                                                        [string]
  --format                                  The format that the GraphQL client c
                                            ode should be generated in.
              [string] [choices: "graphql-codegen", "introspection", "modelgen"]
  --modelTarget                             The modelgen export target. Only app
                                            lies when the `--format` parameter i
                                            s set to `modelgen`
         [string] [choices: "java", "swift", "javascript", "typescript", "dart"]
  --statementTarget                         The graphql-codegen statement export
                                             target. Only applies when the `--fo
                                            rmat` parameter is set to `graphql-c
                                            odegen`
    [string] [choices: "javascript", "graphql", "flow", "typescript", "angular"]
  --typeTarget                              The optional graphql-codegen type ex
                                            port target. Only applies when the `
                                            --format` parameter is set to `graph
                                            ql-codegen`
  [string] [choices: "json", "swift", "ts", "typescript", "flow", "scala", "flow
                                                            -modern", "angular"]
  --modelGenerateIndexRules                 Adds key/index details to iOS models
                                                                       [boolean]
  --modelEmitAuthProvider                   Adds auth provider details to iOS mo
                                            dels                       [boolean]
  --modelRespectPrimaryKeyAttributesOnConn  If enabled, datastore queries will r
  ectionField                               espect the primary + sort key fields
                                            , rather than a defaut id field
                                                                       [boolean]
  --modelGenerateModelsForLazyLoadAndCusto  Generates lazy model type definition
  mSelectionSet                             s, required or amplify-js v5+
                                                                       [boolean]
  --modelAddTimestampFields                 Add read-only timestamp fields in mo
                                            delgen.                    [boolean]
  --modelHandleListNullabilityTransparentl  Configure the nullability of the Lis
  y                                         t and List components in Datastore M
                                            odels generation           [boolean]
  --statementMaxDepth                       Determines how deeply nested to gene
                                            rate graphql statements.    [number]
  --statementTypenameIntrospection          Determines whether to include defaul
                                            t __typename for all generated state
                                            ments                      [boolean]
  --typeMultipleSwiftFiles                  Determines whether or not to generat
                                            e a single API.swift, or multiple pe
                                            r-model swift files.       [boolean]
  --all                                     Show hidden options        [boolean]

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@changeset-bot
Copy link

changeset-bot bot commented Sep 21, 2023

🦋 Changeset detected

Latest commit: 57152fc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-amplify/backend-cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@alharris-at alharris-at force-pushed the generate-client-code-command branch from e219691 to cb03274 Compare September 21, 2023 20:56
package.json Outdated Show resolved Hide resolved
@alharris-at alharris-at force-pushed the generate-client-code-command branch 2 times, most recently from 248f7ce to 9a60b3d Compare September 22, 2023 00:29
@alharris-at alharris-at force-pushed the generate-client-code-command branch from 9a60b3d to dbadc31 Compare September 22, 2023 15:58
@alharris-at alharris-at marked this pull request as ready for review September 22, 2023 16:08
Copy link
Member

@sobolk sobolk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall.

@dpilch dpilch mentioned this pull request Sep 22, 2023
sobolk
sobolk previously approved these changes Sep 25, 2023
@alharris-at alharris-at requested a review from sobolk September 25, 2023 19:10
@alharris-at alharris-at requested a review from dpilch September 25, 2023 19:57
@alharris-at alharris-at merged commit 6ec93ae into main Sep 25, 2023
18 checks passed
@alharris-at alharris-at deleted the generate-client-code-command branch September 25, 2023 20:15
abhi7cr pushed a commit that referenced this pull request Sep 27, 2023
* feat: add mocked generate graphql-client-code to cli

* Update packages/cli/src/commands/generate/generate_command_factory.test.ts

fix: update test name

Co-authored-by: Kamil Sobol <[email protected]>

* chore: add missing descriptions for targets, use new shared backendIdentifierResolver

* chore: remove adapter, we may need to reintroduce in the future, but simplifying until we have an impl in place

* chore: add feature flags

* chore: flip to use real generator, not mocked api

---------

Co-authored-by: Kamil Sobol <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants