• Stars
    star
    3,042
  • Rank 14,131 (Top 0.3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

✏️ Apollo CLI for client tooling (Mostly replaced by Rover)

Apollo CLI

GitHub license npm Get on Slack


[2023-03-29] Note - all apollo service:* commands will reach end-of-life on April 28th, 2023. Refer to this blog post for more details.


[2022-07-07] Are you here for codegen? We highly recommend using graphql-code-generator instead. Codegen in this repo is no longer supported and will be removed completely in a future version. For additional migration details, please see this fantastic writeup by @dotansimha: #2053


[2022-01-21] Note - Upcoming Deprecation Plans: We (Apollo) are working towards fully deprecating this repository and its related projects. Most of the functionality in this repository has been replaced by newer projects and the rest will be soon. We'll share detailed migration documentation when everything here is ready to be officially deprecated, but just a heads up in case you're planning on adopting anything here for a new project (which you still can of course if the tooling here works for you - support for this tooling will be minimal however).


[2021-07-23] Note - Housekeeping: Apollo's GraphQL VSCode extension is no longer housed in this repository. It is now maintained separately in this repo.


Apollo CLI brings together your GraphQL clients and servers with tools for validating your schema, linting your operations for compatibility with your server, and generating static types for improved client-side type safety.

Usage

Disclaimer: The following API documentation is only for the latest version released on NPM, and may not be accurate for previous or future versions.

$ npm install -g apollo
$ apollo COMMAND
running command...
$ apollo (-v|--version|version)
apollo/2.33.11 darwin-arm64 node-v16.14.2
$ apollo --help [COMMAND]
USAGE
  $ apollo COMMAND
...

Commands

apollo client:check

Check a client project against a pushed service

USAGE
  $ apollo client:check

OPTIONS
  -c, --config=config
      Path to your Apollo config file

  -g, --graph=graph
      The ID for the graph in Apollo to operate client commands with.
      Overrides config file if set.

  -v, --variant=variant
      The variant of the graph in Apollo to associate this client to

  --clientName=clientName
      Name of the client that the queries will be attached to

  --clientReferenceId=clientReferenceId
      Reference id for the client which will match ids from client traces,
      will use clientName if not provided

  --clientVersion=clientVersion
      The version of the client that the queries will be attached to

  --endpoint=endpoint
      The URL for the CLI use to introspect your service

  --excludes=excludes
      Glob of files to exclude for GraphQL operations. Caveat: this doesn't
      currently work in watch mode

  --header=header
      Additional header to send during introspection. May be used multiple
      times to add multiple headers. NOTE: The `--endpoint` flag is REQUIRED
      if using the `--header` flag.

  --includes=includes
      Glob of files to search for GraphQL operations. This should be used to
      find queries *and* any client schema extensions

  --key=key
      The API key to use for authentication to Apollo

  --queries=queries
      Deprecated in favor of the includes flag

  --tagName=tagName
      Name of the template literal tag used to identify template literals
      containing GraphQL queries in Javascript/Typescript code

See code: src/commands/client/check.ts

apollo client:codegen [OUTPUT]

Generate static types for GraphQL queries. Can use the published schema in the Apollo registry or a downloaded schema.

USAGE
  $ apollo client:codegen [OUTPUT]

ARGUMENTS
  OUTPUT
      Directory to which generated files will be written.
      - For TypeScript/Flow generators, this specifies a directory relative
      to each source file by default.
      - For TypeScript/Flow generators with the "outputFlat" flag is set,
      and for the Swift generator, this specifies a file or directory
      (absolute or relative to the current working directory) to which:
      - a file will be written for each query (if "output" is a directory)
      - all generated types will be written
      - For all other types, this defines a file (absolute or relative to
      the current working directory) to which all generated types are
      written.

OPTIONS
  -c, --config=config
      Path to your Apollo config file

  -g, --graph=graph
      The ID for the graph in Apollo to operate client commands with.
      Overrides config file if set.

  -v, --variant=variant
      The variant of the graph in Apollo to associate this client to

  --[no-]addTypename
      [default: true] Automatically add __typename to your queries, can be
      unset with --no-addTypename

  --clientName=clientName
      Name of the client that the queries will be attached to

  --clientReferenceId=clientReferenceId
      Reference id for the client which will match ids from client traces,
      will use clientName if not provided

  --clientVersion=clientVersion
      The version of the client that the queries will be attached to

  --customScalarsPrefix=customScalarsPrefix
      Include a prefix when using provided types for custom scalars

  --endpoint=endpoint
      The URL for the CLI use to introspect your service

  --excludes=excludes
      Glob of files to exclude for GraphQL operations. Caveat: this doesn't
      currently work in watch mode

  --globalTypesFile=globalTypesFile
      By default, TypeScript will put a file named "globalTypes.ts" inside
      the "output" directory. Set "globalTypesFile" to specify a different
      path. Alternatively, set "tsFileExtension" to modify the extension of
      the file, for example "d.ts" will output "globalTypes.d.ts"

  --header=header
      Additional header to send during introspection. May be used multiple
      times to add multiple headers. NOTE: The `--endpoint` flag is REQUIRED
      if using the `--header` flag.

  --includes=includes
      Glob of files to search for GraphQL operations. This should be used to
      find queries *and* any client schema extensions

  --key=key
      The API key to use for authentication to Apollo

  --localSchemaFile=localSchemaFile
      Path to one or more local GraphQL schema file(s), as introspection
      result or SDL. Supports comma-separated list of paths (ex.
      `--localSchemaFile=schema.graphql,extensions.graphql`)

  --mergeInFieldsFromFragmentSpreads
      Merge fragment fields onto its enclosing type

  --namespace=namespace
      The namespace to emit generated code into.

  --omitDeprecatedEnumCases
      Omit deprecated enum cases from generated code [Swift only]

  --only=only
      Parse all input files, but only output generated code for the
      specified file [Swift only]

  --operationIdsPath=operationIdsPath
      Path to an operation id JSON map file. If specified, also stores the
      operation ids (hashes) as properties on operation types [currently
      Swift-only]

  --outputFlat
      By default, TypeScript/Flow will put each generated file in a
      directory next to its source file using the value of the "output" as
      the directory name. Set "outputFlat" to put all generated files in the
      directory relative to the current working directory defined by
      "output".

  --passthroughCustomScalars
      Use your own types for custom scalars

  --queries=queries
      Deprecated in favor of the includes flag

  --suppressSwiftMultilineStringLiterals
      Prevents operations from being rendered as multiline strings [Swift
      only]

  --tagName=tagName
      Name of the template literal tag used to identify template literals
      containing GraphQL queries in Javascript/Typescript code

  --target=target
      (required) Type of code generator to use (swift | typescript | flow |
      scala | json | json-modern (exposes raw json types))

  --tsFileExtension=tsFileExtension
      By default, TypeScript will output "ts" files. Set "tsFileExtension"
      to specify a different file extension, for example "d.ts"

  --useFlowExactObjects
      Use Flow exact objects for generated types [flow only]

  --useFlowReadOnlyTypes
      Use read only types for generated types [flow only]. **Deprecated in
      favor of `useReadOnlyTypes`.**

  --useReadOnlyTypes
      Use read only types for generated types [flow | typescript]

  --watch
      Watch for file changes and reload codegen

ALIASES
  $ apollo codegen:generate

See code: src/commands/client/codegen.ts

apollo client:download-schema OUTPUT

Download a schema from Apollo or a GraphQL endpoint in JSON or SDL format

USAGE
  $ apollo client:download-schema OUTPUT

ARGUMENTS
  OUTPUT  [default: schema.json] Path to write the introspection result
          to. Can be `.graphql`, `.gql`, `.graphqls`, or `.json`

OPTIONS
  -c, --config=config
      Path to your Apollo config file

  -g, --graph=graph
      The ID for the graph in Apollo to operate client commands with.
      Overrides config file if set.

  -v, --variant=variant
      The variant of the graph in Apollo to associate this client to

  --clientName=clientName
      Name of the client that the queries will be attached to

  --clientReferenceId=clientReferenceId
      Reference id for the client which will match ids from client traces,
      will use clientName if not provided

  --clientVersion=clientVersion
      The version of the client that the queries will be attached to

  --endpoint=endpoint
      The URL for the CLI use to introspect your service

  --excludes=excludes
      Glob of files to exclude for GraphQL operations. Caveat: this doesn't
      currently work in watch mode

  --header=header
      Additional header to send during introspection. May be used multiple
      times to add multiple headers. NOTE: The `--endpoint` flag is REQUIRED
      if using the `--header` flag.

  --includes=includes
      Glob of files to search for GraphQL operations. This should be used to
      find queries *and* any client schema extensions

  --key=key
      The API key to use for authentication to Apollo

  --queries=queries
      Deprecated in favor of the includes flag

  --tagName=tagName
      Name of the template literal tag used to identify template literals
      containing GraphQL queries in Javascript/Typescript code

See code: src/commands/client/download-schema.ts

apollo client:extract OUTPUT

Extract queries from a client

USAGE
  $ apollo client:extract OUTPUT

ARGUMENTS
  OUTPUT  [default: manifest.json] Path to write the extracted queries to

OPTIONS
  -c, --config=config
      Path to your Apollo config file

  -g, --graph=graph
      The ID for the graph in Apollo to operate client commands with.
      Overrides config file if set.

  -v, --variant=variant
      The variant of the graph in Apollo to associate this client to

  --clientName=clientName
      Name of the client that the queries will be attached to

  --clientReferenceId=clientReferenceId
      Reference id for the client which will match ids from client traces,
      will use clientName if not provided

  --clientVersion=clientVersion
      The version of the client that the queries will be attached to

  --endpoint=endpoint
      The URL for the CLI use to introspect your service

  --excludes=excludes
      Glob of files to exclude for GraphQL operations. Caveat: this doesn't
      currently work in watch mode

  --header=header
      Additional header to send during introspection. May be used multiple
      times to add multiple headers. NOTE: The `--endpoint` flag is REQUIRED
      if using the `--header` flag.

  --includes=includes
      Glob of files to search for GraphQL operations. This should be used to
      find queries *and* any client schema extensions

  --key=key
      The API key to use for authentication to Apollo

  --preserveStringAndNumericLiterals
      Disable redaction of string and numerical literals.  Without this
      flag, these values will be replaced with empty strings (`''`) and
      zeroes (`0`) respectively.  This redaction is intended to avoid
      inadvertently outputting potentially personally identifiable
      information (e.g. embedded passwords  or API keys) into operation
      manifests

  --queries=queries
      Deprecated in favor of the includes flag

  --tagName=tagName
      Name of the template literal tag used to identify template literals
      containing GraphQL queries in Javascript/Typescript code

See code: src/commands/client/extract.ts

apollo client:push

Register operations with Apollo, adding them to the safelist

USAGE
  $ apollo client:push

OPTIONS
  -c, --config=config
      Path to your Apollo config file

  -g, --graph=graph
      The ID for the graph in Apollo to operate client commands with.
      Overrides config file if set.

  -v, --variant=variant
      The variant of the graph in Apollo to associate this client to

  --clientName=clientName
      Name of the client that the queries will be attached to

  --clientReferenceId=clientReferenceId
      Reference id for the client which will match ids from client traces,
      will use clientName if not provided

  --clientVersion=clientVersion
      The version of the client that the queries will be attached to

  --endpoint=endpoint
      The URL for the CLI use to introspect your service

  --excludes=excludes
      Glob of files to exclude for GraphQL operations. Caveat: this doesn't
      currently work in watch mode

  --header=header
      Additional header to send during introspection. May be used multiple
      times to add multiple headers. NOTE: The `--endpoint` flag is REQUIRED
      if using the `--header` flag.

  --includes=includes
      Glob of files to search for GraphQL operations. This should be used to
      find queries *and* any client schema extensions

  --key=key
      The API key to use for authentication to Apollo

  --queries=queries
      Deprecated in favor of the includes flag

  --tagName=tagName
      Name of the template literal tag used to identify template literals
      containing GraphQL queries in Javascript/Typescript code

See code: src/commands/client/push.ts

apollo help [COMMAND]

display help for apollo

USAGE
  $ apollo help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

apollo plugins

List installed plugins.

USAGE
  $ apollo plugins

OPTIONS
  --core  Show core plugins.

EXAMPLE
  $ apollo plugins

See code: @oclif/plugin-plugins

apollo plugins:inspect PLUGIN...

Displays installation properties of a plugin.

USAGE
  $ apollo plugins:inspect PLUGIN...

ARGUMENTS
  PLUGIN  [default: .] Plugin to inspect.

OPTIONS
  -h, --help     Show CLI help.
  -v, --verbose

EXAMPLE
  $ apollo plugins:inspect myplugin

See code: @oclif/plugin-plugins

apollo plugins:install PLUGIN...

Installs a plugin into the CLI.

USAGE
  $ apollo plugins:install PLUGIN...

ARGUMENTS
  PLUGIN  Plugin to install.

OPTIONS
  -f, --force    Run yarn install with force flag.
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Can be installed from npm or a git url.

  Installation of a user-installed plugin will override a core plugin.

  e.g. If you have a core plugin that has a 'hello' command, installing a
  user-installed plugin with a 'hello' command will override the core
  plugin implementation. This is useful if a user needs to update core
  plugin functionality in the CLI without the need to patch and update the
   whole CLI.

ALIASES
  $ apollo plugins:add

EXAMPLES
  $ apollo plugins:install myplugin
  $ apollo plugins:install https://github.com/someuser/someplugin
  $ apollo plugins:install someuser/someplugin

See code: @oclif/plugin-plugins

apollo plugins:link PLUGIN

Links a plugin into the CLI for development.

USAGE
  $ apollo plugins:link PLUGIN

ARGUMENTS
  PATH  [default: .] path to plugin

OPTIONS
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Installation of a linked plugin will override a user-installed or core
  plugin.

  e.g. If you have a user-installed or core plugin that has a 'hello'
  command, installing a linked plugin with a 'hello' command will override
   the user-installed or core plugin implementation. This is useful for
  development work.

EXAMPLE
  $ apollo plugins:link myplugin

See code: @oclif/plugin-plugins

apollo plugins:uninstall PLUGIN...

Removes a plugin from the CLI.

USAGE
  $ apollo plugins:uninstall PLUGIN...

ARGUMENTS
  PLUGIN  plugin to uninstall

OPTIONS
  -h, --help     Show CLI help.
  -v, --verbose

ALIASES
  $ apollo plugins:unlink
  $ apollo plugins:remove

See code: @oclif/plugin-plugins

apollo plugins:update

Update installed plugins.

USAGE
  $ apollo plugins:update

OPTIONS
  -h, --help     Show CLI help.
  -v, --verbose

See code: @oclif/plugin-plugins

apollo service:check

[DEPRECATED] Check a service against known operation workloads to find breaking changes

USAGE
  $ apollo service:check

OPTIONS
  -c, --config=config
      Path to your Apollo config file

  -g, --graph=graph
      The ID of the graph in Apollo to check your proposed schema changes
      against. Overrides config file if set.

  -v, --variant=variant
      The variant to check the proposed schema against

  --author=author
      The author to associate with this proposed schema

  --branch=branch
      The branch name to associate with this check

  --commitId=commitId
      The SHA-1 hash of the commit to associate with this check

  --endpoint=endpoint
      The URL for the CLI use to introspect your service

  --header=header
      Additional header to send during introspection. May be used multiple
      times to add multiple headers. NOTE: The `--endpoint` flag is REQUIRED
      if using the `--header` flag.

  --ignoreFailures
      Exit with status 0 when the check completes, even if errors are found

  --json
      Output result in json, which can then be parsed by CLI tools such as
      jq.

  --key=key
      The API key to use for authentication to Apollo

  --localSchemaFile=localSchemaFile
      Path to one or more local GraphQL schema file(s), as introspection
      result or SDL. Supports comma-separated list of paths (ex.
      `--localSchemaFile=schema.graphql,extensions.graphql`)

  --markdown
      Output result in markdown.

  --queryCountThreshold=queryCountThreshold
      Minimum number of requests within the requested time window for a
      query to be considered.

  --queryCountThresholdPercentage=queryCountThresholdPercentage
      Number of requests within the requested time window for a query to be
      considered, relative to total request count. Expected values are
      between 0 and 0.05 (minimum 5% of total request volume)

  --serviceName=serviceName
      Provides the name of the implementing service for a federated graph.
      This flag will indicate that the schema is a partial schema from a
      federated service

  --validationPeriod=validationPeriod
      The size of the time window with which to validate the schema against.
      You may provide a number (in seconds), or an ISO8601 format duration
      for more granularity (see:
      https://en.wikipedia.org/wiki/ISO_8601#Durations)

DESCRIPTION
  -----------------------------------------------------------------
  DEPRECATED: This command will be removed from the `apollo` CLI in
  its next major version. Replacement functionality is available in
  the new Apollo Rover CLI: https://go.apollo.dev/t/migration
  -----------------------------------------------------------------

ALIASES
  $ apollo schema:check

See code: src/commands/service/check.ts

apollo service:delete

[DEPRECATED] Delete a federated service from Apollo and recompose remaining services

USAGE
  $ apollo service:delete

OPTIONS
  -c, --config=config        Path to your Apollo config file

  -g, --graph=graph          The ID of the graph in Apollo for which to
                             delete an implementing service. Overrides
                             config file if set.

  -v, --variant=variant      The variant to delete the implementing
                             service from

  -y, --yes                  Bypass confirmation when deleting a service

  --endpoint=endpoint        The URL for the CLI use to introspect your
                             service

  --header=header            Additional header to send during
                             introspection. May be used multiple times to
                             add multiple headers. NOTE: The `--endpoint`
                             flag is REQUIRED if using the `--header`
                             flag.

  --key=key                  The API key to use for authentication to
                             Apollo

  --serviceName=serviceName  (required) Provides the name of the
                             implementing service for a federated graph

DESCRIPTION
  -----------------------------------------------------------------
  DEPRECATED: This command will be removed from the `apollo` CLI in
  its next major version. Replacement functionality is available in
  the new Apollo Rover CLI: https://go.apollo.dev/t/migration
  -----------------------------------------------------------------

See code: src/commands/service/delete.ts

apollo service:download OUTPUT

[DEPRECATED] Download the schema from your GraphQL endpoint.

USAGE
  $ apollo service:download OUTPUT

ARGUMENTS
  OUTPUT  [default: schema.json] Path to write the introspection result
          to. Supports .json output only.

OPTIONS
  -c, --config=config      Path to your Apollo config file

  -g, --graph=graph        The ID of the graph in the Apollo registry for
                           which to download the schema for. Overrides
                           config file if provided.

  -k, --skipSSLValidation  Allow connections to an SSL site without certs

  -v, --variant=variant    The variant to download the schema of

  --endpoint=endpoint      The URL for the CLI use to introspect your
                           service

  --header=header          Additional header to send during introspection.
                           May be used multiple times to add multiple
                           headers. NOTE: The `--endpoint` flag is
                           REQUIRED if using the `--header` flag.

  --key=key                The API key to use for authentication to Apollo

DESCRIPTION
  -----------------------------------------------------------------
  DEPRECATED: This command will be removed from the `apollo` CLI in
  its next major version. Replacement functionality is available in
  the new Apollo Rover CLI: https://go.apollo.dev/t/migration
  -----------------------------------------------------------------

ALIASES
  $ apollo schema:download

See code: src/commands/service/download.ts

apollo service:list

[DEPRECATED] List the services in a graph

USAGE
  $ apollo service:list

OPTIONS
  -c, --config=config    Path to your Apollo config file

  -g, --graph=graph      The ID of the graph in the Apollo registry for
                         which to list implementing services. Overrides
                         config file if set.

  -v, --variant=variant  The variant to list implementing services for

  --endpoint=endpoint    The URL for the CLI use to introspect your
                         service

  --header=header        Additional header to send during introspection.
                         May be used multiple times to add multiple
                         headers. NOTE: The `--endpoint` flag is REQUIRED
                         if using the `--header` flag.

  --key=key              The API key to use for authentication to Apollo

DESCRIPTION
  -----------------------------------------------------------------
  DEPRECATED: This command will be removed from the `apollo` CLI in
  its next major version. Replacement functionality is available in
  the new Apollo Rover CLI: https://go.apollo.dev/t/migration
  -----------------------------------------------------------------

See code: src/commands/service/list.ts

apollo service:push

[DEPRECATED] Push a service definition to Apollo

USAGE
  $ apollo service:push

OPTIONS
  -c, --config=config
      Path to your Apollo config file

  -g, --graph=graph
      The ID of the graph in Apollo to publish your service to. Overrides
      config file if set.

  -v, --variant=variant
      The variant to publish your service to in Apollo

  --author=author
      The author to associate with this publication

  --branch=branch
      The branch name to associate with this publication

  --commitId=commitId
      The SHA-1 hash of the commit to associate with this publication

  --endpoint=endpoint
      The URL for the CLI use to introspect your service

  --header=header
      Additional header to send during introspection. May be used multiple
      times to add multiple headers. NOTE: The `--endpoint` flag is REQUIRED
      if using the `--header` flag.

  --key=key
      The API key to use for authentication to Apollo

  --localSchemaFile=localSchemaFile
      Path to one or more local GraphQL schema file(s), as introspection
      result or SDL. Supports comma-separated list of paths (ex.
      `--localSchemaFile=schema.graphql,extensions.graphql`)

  --serviceName=serviceName
      Provides the name of the implementing service for a federated graph

  --serviceRevision=serviceRevision
      Provides a unique revision identifier for a change to an implementing
      service on a federated service push. The default of this is a git sha

  --serviceURL=serviceURL
      Provides the url to the location of the implementing service for a
      federated graph

DESCRIPTION
  -----------------------------------------------------------------
  DEPRECATED: This command will be removed from the `apollo` CLI in
  its next major version. Replacement functionality is available in
  the new Apollo Rover CLI: https://go.apollo.dev/t/migration
  -----------------------------------------------------------------

ALIASES
  $ apollo schema:publish

See code: src/commands/service/push.ts

Configuration

The Apollo CLI and VS Code extension can be configured with an Apollo config file. Apollo configuration is stored as a plain object in an apollo.config.js file which exports the configuration. For more information about configuring an Apollo project, see: https://www.apollographql.com/docs/devtools/apollo-config/.

Note: the use of the apollo key in the project's package.json file for configuration is deprecated, and will no longer be supported in Apollo v3

You'll need to set up your Apollo configuration for all the features of the Apollo CLI and VS Code extension to work correctly. For full details on how to do that, visit our docs. A basic configuration (apollo.config.js style) looks something like this:

module.exports = {
  client: {
    name: "My Client Project",
    service: "my-service-name"
  }
};

Code Generation

Accompanying Libraries

See Apollo iOS for details on the mapping from GraphQL results to Swift types, as well as runtime support for executing queries and mutations. For Scala, see React Apollo Scala.js for details on how to use generated Scala code in a Scala.js app with Apollo Client.

gql template support

If the source file for generation is a JavaScript or TypeScript file, the codegen will try to extrapolate the queries inside the gql tag templates.

The tag name is configurable using the CLI --tagName option.

Typescript and Flow

When using the codegen command with Typescript or Flow, make sure to add the __typename introspection field to every selection set within your graphql operations.

If you're using a client like apollo-client that does this automatically for your GraphQL operations, pass in the --addTypename option to apollo codegen:generate to make sure the generated Typescript and Flow types have the __typename field as well. This is required to ensure proper type generation support for GraphQLUnionType and GraphQLInterfaceType fields.

Why is the __typename field required?

Using the type information from the GraphQL schema, we can infer the possible types for fields. However, in the case of a GraphQLUnionType or GraphQLInterfaceType, there are multiple types that are possible for that field. This is best modeled using a disjoint union with the __typename as the discriminant.

For example, given a schema:

...

interface Character {
  name: String!
}

type Human implements Character {
  homePlanet: String
}

type Droid implements Character {
  primaryFunction: String
}

...

Whenever a field of type Character is encountered, it could be either a Human or Droid. Human and Droid objects will have a different set of fields. Within your application code, when interacting with a Character you'll want to make sure to handle both of these cases.

Given this query:

query Characters {
  characters(episode: NEW_HOPE) {
    name

    ... on Human {
      homePlanet
    }

    ... on Droid {
      primaryFunction
    }
  }
}

Apollo Codegen will generate a union type for Character.

export type CharactersQuery = {
  characters: Array<
    | {
        __typename: "Human",
        name: string,
        homePlanet: ?string
      }
    | {
        __typename: "Droid",
        name: string,
        primaryFunction: ?string
      }
  >
};

This type can then be used as follows to ensure that all possible types are handled:

function CharacterFigures({ characters }: CharactersQuery) {
  return characters.map(character => {
    switch (character.__typename) {
      case "Human":
        return (
          <HumanFigure
            homePlanet={character.homePlanet}
            name={character.name}
          />
        );
      case "Droid":
        return (
          <DroidFigure
            primaryFunction={character.primaryFunction}
            name={character.name}
          />
        );
    }
  });
}

Contributing

Build Status

This repo is composed of multiple packages. The apollo-cli contains the core CLI commands. The apollo-codegen-core package contains all the compiler APIs needed to implement code generation support for new languages. The other apollo-codegen-* packages implement code generation support for individual languages.

Running tests locally:

npm install
npm test

You can also run npm commands within package folders after you have bootstrapped the repository (part of npm install).

Note: if you have issues, try npm run clean && npm i to get a fresh install of the packages. Occasionally problems arise when removed dependencies stay around

Nock tests

To display the debugging messages for nock, run the following command:

DEBUG=nock.* npm test

It can also be helpful to print standard out during testing. To enable logging, add the following configuration to the stdout function call during test creation:

.stdout({ print: true })

Active Development / Debugging

To simplify the development process, you may want to step through and debug commands whose behavior you're modifying. To do this, run the executable with node in debug mode like so, where <command> is a valid CLI command like client:check or service:push:

node --inspect-brk=9002 packages/apollo/bin/run <command>

If you're using VS Code, you can run the included "Attach to CLI Debugger" launch task and debug right from VS Code! Otherwise, you may use the Chrome inspector or other Node debugger of your choice.

Regenerating Mocked Network Data

Some integration tests rely on mocked server data (service:check for example). Mock data is generated by making real network requests and recording those requests with nock's recording feature. Stop mocking network calls and add nock.recorder.rec() before network calls are made. For service:check, change apiKey to a real Apollo API key. Then run the tests and nock will output code to mock requests to the console. You can (and probably should) pare down the request to be less brittle (by only checking for an operation name, for example). See src/commands/service/__tests__/check.test.ts for an example of how a mocked network request will look.

Publishing

  1. Make sure the CHANGELOG.md is updated with all changes committed since the last release. Make sure the versions for each package to update are correct.
  2. Run npm run release:version-bump -- <bumpish>
    • Can use major, minor, patch, prepatch, etc for the bump type. If not used, the command will prompt and ask for the bump type.
    • This command updates git tags locally and on GitHub
  3. Run npm run release:start-ci-publish locally
    • IMPORTANT: If publishing a prerelease (like alpha/beta/rc), set the tag that NPM will use to publish with the APOLLO_DIST_TAG environment variable. By default, if this isn't set, NPM will publish the prerelease to the latest tag (which isn't what we'd want).
    • Pushes a publish/XXXXXXXXXX tag to GitHub to trigger circle CI build
  4. Circle will notify the appropriate Apollo team slack channel when ready to release
    • Slack channel member will confirm through the Apollo Deploy Bot
    • Circle will release to all channels (npm, cli binary to s3, vscode marketplace)
    • Another slack bot notification will confirm success of release.

Maintainers

More Repositories

1

apollo-client

🚀  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
TypeScript
18,905
star
2

apollo-server

🌍  Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
TypeScript
13,522
star
3

react-apollo

♻️ React integration for Apollo Client
JavaScript
6,887
star
4

apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
Swift
3,737
star
5

apollo-kotlin

🤖  A strongly-typed, caching GraphQL client for the JVM, Android, and Kotlin multiplatform.
Kotlin
3,382
star
6

apollo

🚀 Open source tools for GraphQL. Central repo for discussion.
JavaScript
2,626
star
7

graphql-tag

A JavaScript template literal tag that parses GraphQL queries
TypeScript
2,275
star
8

graphql-subscriptions

📰 A small module that implements GraphQL subscriptions for Node.js
TypeScript
1,567
star
9

subscriptions-transport-ws

🔃 A WebSocket client + server for GraphQL subscriptions
TypeScript
1,524
star
10

apollo-client-devtools

Apollo Client browser developer tools.
TypeScript
1,471
star
11

apollo-link

🔗 Interface for fetching and modifying control flow of GraphQL requests
TypeScript
1,438
star
12

apollo-link-state

✨ Manage your application's state with Apollo!
TypeScript
1,405
star
13

apollo-cache-persist

🎏 Simple persistence for all Apollo Cache implementations
TypeScript
1,363
star
14

fullstack-tutorial

🚀 The Apollo platform tutorial app
TypeScript
1,241
star
15

eslint-plugin-graphql

🚦 Check your GraphQL query strings against a schema.
JavaScript
1,194
star
16

apollo-link-rest

Use existing REST endpoints with GraphQL
TypeScript
783
star
17

router

A configurable, high-performance routing runtime for Apollo Federation 🚀
Rust
737
star
18

federation

🌐  Build and scale a single data graph across multiple services with Apollo's federation gateway.
TypeScript
638
star
19

apollo-fetch

🐶 Lightweight GraphQL client that supports middleware and afterware
TypeScript
576
star
20

apollo-rs

Spec compliant GraphQL Tools in Rust.
Rust
556
star
21

reason-apollo

Reason binding for Apollo Client and React Apollo
Reason
555
star
22

federation-demo

Federation 2 supersedes this demo and this example is no longer the newest. See https://www.apollographql.com/docs/federation/ for migration steps!
JavaScript
504
star
23

ac3-state-management-examples

✨ Learn Apollo Client 3's state management best practices
TypeScript
491
star
24

apollo-tracing

A GraphQL extension for performance tracing
475
star
25

persistgraphql

A build tool for GraphQL projects.
TypeScript
424
star
26

rover

✨🤖 🐶 The CLI for Apollo GraphOS
Rust
389
star
27

gatsby-theme-apollo

💜 Themes that we use to build Gatsby sites at Apollo
JavaScript
371
star
28

apollo-client-nextjs

Apollo Client support for the Next.js App Router
TypeScript
337
star
29

apollo-link-persisted-queries

Persisted Query support with Apollo Link
TypeScript
307
star
30

xcode-graphql

🛠 Xcode add-ons that add syntax highlighting for GraphQL query document files
Shell
276
star
31

apollo-studio-community

🎡  GraphQL developer portal featuring an IDE (Apollo Explorer), auto-documentation, metrics reporting, and more. This repo is for issues, feature requests, and preview docs. 📬
246
star
32

federation-jvm

JVM support for Apollo Federation
Java
233
star
33

supergraph-demo-fed2

🍿 Supergraph demo for Federation 2 and Apollo Router
Shell
155
star
34

apollo-cache-control

A GraphQL extension for cache control
146
star
35

principled-graphql

📈 Best practices for implementing and scaling a data graph
JavaScript
145
star
36

supergraph-demo

🍿 Compose subgraphs into a Federation v1 supergraph at build-time with static composition to power a federated graph router at runtime.
Shell
131
star
37

apollo-feature-requests

🧑‍🚀 Apollo Client Feature Requests | (no 🐛 please).
128
star
38

spotify-showcase

A Spotify clone that showcases the Apollo GraphQL platform.
TypeScript
109
star
39

meteor-integration

🚀 meteor add apollo
JavaScript
108
star
40

frontpage-ios-app

📄 Apollo "hello world" app, for iOS
Swift
101
star
41

space-kit

👩‍🚀 Home base for Apollo's design system: https://space-kit.netlify.com
TypeScript
89
star
42

apollo-scalajs

Use Apollo GraphQL from Scala.js apps!
Scala
88
star
43

invariant-packages

Packages for working with invariant(condition, message) assertions
TypeScript
86
star
44

apollo-federation-subgraph-compatibility

A repo to test subgraph libraries compatibility with the Apollo Federation Specification
TypeScript
73
star
45

starwars-server

JavaScript
72
star
46

blog

📝 Blog website built with Wordpress and Gatsby
JavaScript
68
star
47

iOSTutorial

The tutorial application for the Apollo iOS SDK
Swift
65
star
48

odyssey-lift-off-part1

JavaScript
61
star
49

federation-jvm-spring-example

Apollo Federation JVM example implementation using Spring for GraphQL
Java
56
star
50

vscode-graphql

Apollo GraphQL VS Code extension
TypeScript
49
star
51

apollo-kotlin-tutorial

The code for the Apollo Kotlin Tutorial
Kotlin
49
star
52

docs-examples

Example code supporting the Apollo docs
TypeScript
46
star
53

apollo-kotlin-2-tutorial

The code for the Apollo Android Tutorial
Kotlin
38
star
54

iOSCodegenTemplate

A template for the code you need to set up to get Swift Scripting up and running.
Swift
38
star
55

docs

📚 Apollo's docs framework
MDX
36
star
56

apollo-workbench-vscode

Apollo Workbench is a design tool that facilitates planning changes to your supergraph. It enables you to understand the overall composition and execution of any given query at design time.
TypeScript
36
star
57

react-apollo-error-template

Apollo Client issue reproduction.
JavaScript
33
star
58

apollo-utils

Monorepo of common utilities related to Apollo and GraphQL
TypeScript
32
star
59

federation-rs

Contains source code for Apollo Federation's Rust<--> JavaScript interop
Rust
32
star
60

federation-migration-example

🚀Example app migrated from schema stitching to Apollo federation
JavaScript
32
star
61

odyssey-lift-off-part5-server

Odyssey Lift-off V - Server - Course Companion App
JavaScript
31
star
62

embeddable-explorer

TypeScript
31
star
63

odyssey-lift-off-part5-client

Odyssey Lift-off V - Client - Course Companion App
JavaScript
28
star
64

GraphiQL-Subscriptions-Fetcher

GraphiQL's fetcher that supports GraphQL-Subscriptions with the `subscriptions-transport-ws` package
TypeScript
28
star
65

datasource-rest

A caching data source for REST APIs
TypeScript
28
star
66

supergraph-demo-k8s-graph-ops

Archived: GitOps config repo for an Apollo GraphQL federated graph with a supergraph router and subgraph services deployed to Kubernetes.
Shell
27
star
67

odyssey-lift-off-part2

Odyssey Lift-off Part 2 Course Companion App
JavaScript
25
star
68

apollo-graphql-stream-scenes

This is used for hosting streaming scenes for OBS - for Apollo GraphQL stream
JavaScript
20
star
69

spacex

A re-creation of https://github.com/SpaceXLand/api
TypeScript
18
star
70

odyssey-voyage-I

JavaScript
14
star
71

federation-hotchocolate

HotChocolate support for Apollo Federation
C#
14
star
72

typescript-repo-template

A template for TypeScript projects with pre-configured tooling
TypeScript
14
star
73

odyssey-lift-off-part3

Odyssey Lift-off Part 3 Course Companion App
JavaScript
14
star
74

federation-next

Home of the rust rewrite of federation core (composition & query planning)
Rust
14
star
75

apollo-ios-dev

Apollo iOS Development Repo
Swift
14
star
76

odyssey-lift-off-part4

Odyssey Lift-off Part 4 Course Companion App
JavaScript
13
star
77

subgraph-template-typescript-apollo-server

A Typescript template for Apollo Server as a subgraph using Apollo Federation
TypeScript
13
star
78

community

Apollo community guidelines
JavaScript
13
star
79

design-principles

Where we are defining and collaborating on our Apollo internal design principles (individually and collaboratively). This is a public repo, but intended only for use by Apollo employees.
13
star
80

core-schema-js

Typescript library for processing core schemas
TypeScript
12
star
81

apollo-client-swift-playground

Swift
11
star
82

test-span

Rust
11
star
83

subgraph-template-typescript-apollo-server-boilerplate

A template for a minimal setup Apollo Server 4.x using TypeScript
TypeScript
11
star
84

apollo-ios-pagination

Swift
10
star
85

specs

Apollo Library of Technical Specifications
CSS
10
star
86

apollo-midnight

A VS Code color theme based on Apollo Studio Explorer color palette.
9
star
87

devhub

🔭 Explore all the latest resources for building apps with Apollo
JavaScript
8
star
88

serde_json_bytes

a JSON Value object with strings backed by Bytes, parsed by serde_json
Rust
8
star
89

hack-the-supergraph

JavaScript
8
star
90

next-apollo-example

Template for creating Apollo Client + Next.js reproductions
JavaScript
8
star
91

router-biscuit-plugin

⚠️experimental⚠️ plugin for the router using Biscuit tokens for authorization
Rust
7
star
92

apollo-ios-codegen

Apollo iOS Code Generation
Swift
7
star
93

odyssey-lift-off-lab

Odyssey Lift-off Lab starter repo
JavaScript
7
star
94

zen-observable-ts

Thin wrapper around zen-observable and @types/zen-observable, to support ESM exports
JavaScript
7
star
95

router-template

A general purpose self-hosted Apollo Router template connected to GraphOS
Dockerfile
7
star
96

introspector-gadget

GraphQL introspection utilities
Rust
6
star
97

client-router-e2e-tests

Apollo Client ↔️ Router E2E Test Suite
JavaScript
6
star
98

subgraph-template-rust-async-graphql

A boilerplate template project for building a subgraph with async-graphql
Rust
6
star
99

odyssey-voyage-II-server

The course companion app to Odyssey's Federation series.
JavaScript
5
star
100

apollo-server-starter

A starter/demonstration repo of Apollo Server
JavaScript
5
star