Sourcegraph GraphQL API examples

This page demonstrates a few example GraphQL queries for the Sourcegraph GraphQL API.

GraphQL query Description Example use case
Perform a search query and get results Returns the search result metadata (whether or not the search result limit was hit, if the search timed out, etc.) and the actual results of the search query, which can be one of three types: Repository, FileMatch, or CommitSearchResult. Search for a new framework or API that you are using (or have deprecated) and determine all of the repositories that haven't yet been migrated.
List the first 1,000 enabled repositories Returns the name, description, and URL of the first 1,000 repositories that are enabled on the Sourcegraph server (in order of their creation date).
List all files in a repository Returns every file in the repository, its path (relative to the repository root), whether or not it is a directory or plain file, and what the URL path to the file is. List all of the files in each repository of your organization (when combined with the "List the first 1000 enabled repositories" example above) to determine which of your repositories are missing important files like READMEs, LICENSEs, and Dockerfiles.
List the languages used in a repository Returns the primary language of the repository as well as a list of all the languages used in the repository. List all of the languages in each repository of your organization (when combined with the "List the first 1000 enabled repositories" example above) to determine how many repos use each language across your entire organization.