Code AI platform with Code Search & Cody
Go to file
Felix Kling 031bb871fb
svelte: Towards a better data fetching and GraphQL authoring experience (#59383)
This PR refactors almost all of the prototypes GraphQL queries to take advantage of GraphQLs compossibility via fragments. The goal is to provide a more structured approach to authoring and executing GraphQL queries, with the following advantages:
- Data dependency co-location makes it easier to maintain/extend individual components.
- Data fetching happens in specific, predictable places (layout and page loaders).

On a high level it works like this:

- Components declare their data dependencies in `<Component>.gql` files next to them. Thanks to GraphQL code generation they can import the corresponding TypeScript types via `import type { SomeFragment} from './<Component>.gql'`.
- Higher level components compose the fragments of their children.
- At the page/layout level `page.gql`/`layout.gql` files define the queries, composed from the data dependencies of the page/layout.
- The page/layout data loaders can import queries directly from the corresponding `.gql` file.

Authoring the `.gql` files should be relatively easily if the graphql language server is setup. The changes in the `.graphlrc` file make all fragments globally available which means that every fragment needs to be unique and we don't need to use unofficial `#import` directives inside `.gql` files.

There are a couple of things to consider though:

- Caching: If different pages/layouts fetch the same data with different queries, we won't leverage caching without additional setup. That's something I still need to look into. That also means that sometimes we might want to use a shared queries instead of composition/co-location, if caching is more important.
- Shared layout data: Some data fetched in layouts is accessed by sub-layouts/sub-pages, but the layout doesn't know which sub-layout/sub-page is loaded, making query composition more difficult. So it far it seems that data shared this way is rather limited/constrained. So my current approach is to have components/pages define fragments following a specific naming convention, and have the loaders that provide this data compose them. Examples for this is `SearchInput_AuthorizedUser` and `RepoPage_ResolvedRevision`.
  This is not ideal because it has to be remembered to embed this fragment in the right place, but it's not worse than the current situation (where we often don't know where the query providing some data is defined).
- On demand data fetching: Not all data is necessary for rendering a page, some data is only fetched when in response to some user interaction. The layout/page loader should still be the place that executes the query, but instead of doing it on page load it passes a function to the page to fetch the data on demand. This way we can maintain data co-location and fetching in loaders. For an example see the `fetchCommitHistory` function.

NOTE: I expect there to be changes to this approach as we uncover more data loading requirements.
2024-01-09 10:33:30 +01:00
.aspect build: use small low-cost Aspect Workflows runners for buildifier, gazelle & finalization steps (#59204) 2023-12-22 10:45:15 +00:00
.buildkite ci: cleanup hooks and clear containers on aspect (#59293) 2024-01-04 16:15:12 +00:00
.github Stop tagging @mrnugget (#59184) 2023-12-21 22:04:15 +00:00
.vscode Remove App from codebase (#59115) 2023-12-21 01:07:05 +01:00
client svelte: Towards a better data fetching and GraphQL authoring experience (#59383) 2024-01-09 10:33:30 +01:00
cmd Adding Config options for Siteadmins to configure whether clients can use Chat/autocomplete/commands (#59229) 2024-01-09 01:01:09 +00:00
dev search: disable structural search by default (#57584) 2024-01-09 10:11:11 +01:00
doc Adjust blobstore latency alert (#59382) 2024-01-09 08:34:27 +02:00
docker-images bazel: updates for hermetic_cc_toolchain + zig bump (#59333) 2024-01-08 17:07:57 +00:00
internal search: disable structural search by default (#57584) 2024-01-09 10:11:11 +01:00
lib Bump go-mockgen to include lenient type checking (#59397) 2024-01-08 21:20:24 +00:00
migrations Add creator_id and last_updater_id to external_services (#57603) 2023-12-01 11:16:13 -08:00
monitoring Adjust blobstore latency alert (#59382) 2024-01-09 08:34:27 +02:00
schema search: disable structural search by default (#57584) 2024-01-09 10:11:11 +01:00
testing Make sure we test gRPC in CI suites (#59094) 2023-12-19 00:35:56 +01:00
third_party bazel: updates for hermetic_cc_toolchain + zig bump (#59333) 2024-01-08 17:07:57 +00:00
third-party-licenses chore: update third-party licenses (#59370) 2024-01-08 10:12:45 +02:00
tools/release release: sourcegraph@5.2.3 (#58362) 2023-11-16 16:35:19 -05:00
ui/assets Revert "use vite for web builds (#58228)" (#59132) 2023-12-20 16:23:45 -03:00
wolfi-images wolfi: add redis cli to server image (#58802) 2023-12-06 15:45:42 +02:00
wolfi-packages Build: bump hash for perforce API (#59396) 2024-01-08 13:20:46 -08:00
.bazel_fix_commands.json bazel: add command sets that uses bazel under the hood (#48460) 2023-03-02 11:31:51 +01:00
.bazelignore Remove App from codebase (#59115) 2023-12-21 01:07:05 +01:00
.bazeliskrc chore: upgrade to Aspect CLI 5.8.19 (#59203) 2024-01-02 15:13:24 +01:00
.bazelrc bazel: updates for hermetic_cc_toolchain + zig bump (#59333) 2024-01-08 17:07:57 +00:00
.bazelversion ci/bazel: use bazel 7 (#58915) 2024-01-02 19:54:03 +01:00
.dockerignore use esbuild for client/web builds (#57365) 2023-10-23 10:59:06 -07:00
.editorconfig proto: Add editorconfig to ident using two spaces (#57281) 2023-10-03 00:39:42 +00:00
.eslintrc.js fix useProjectService TypeScript ESLint config (#58585) 2023-11-30 00:24:24 -08:00
.gitattributes github: show bazel diff again (#54719) 2023-07-07 16:43:45 +00:00
.gitignore ci: fix incorrect usage of target determinator (#59171) 2023-12-21 15:50:29 +00:00
.graphqlrc.yml
.hadolint.yaml bump comby version to 1.7.1 (#35830) 2022-05-20 20:12:01 -07:00
.mailmap mailmap: add entries for Eric and Renovate (#50966) 2023-04-25 09:42:22 +02:00
.mocharc.js reapply "switch from jest to vitest for faster, simpler tests (#57886)" (#58145) 2023-11-07 12:00:18 +02:00
.npmrc pnpm: remove update notifier message (#51630) 2023-05-10 08:53:39 +02:00
.percy.yml ci: percy defer snapshots upload (#54116) 2023-06-25 18:57:49 -07:00
.pre-commit-config.yaml local: don't let pre-commit run no DB md files (#58094) 2023-11-03 08:50:10 +00:00
.prettierignore Remove App from codebase (#59115) 2023-12-21 01:07:05 +01:00
.stylelintignore rework plugin structure and implement frontside blogpost (#46883) 2023-02-15 11:49:51 +02:00
.stylelintrc.json web: drop bootstrap depenedency (#41401) 2022-09-07 03:11:26 -07:00
.swcrc use swc instead of babel for faster bazel typescript transpilation (#57912) 2023-11-02 22:49:03 -07:00
.tool-versions Dev tool: python script for text clustering based on local embeddings (#58691) 2023-12-04 09:27:14 -05:00
.trivyignore ci: ignore benign CVE-2021-43816 in prometheus (#31069) 2022-02-11 16:49:10 +00:00
BUILD.bazel bazel: first pass at moving moving logging linting into nogo (#58910) 2024-01-02 10:07:25 -08:00
CHANGELOG.md search: disable structural search by default (#57584) 2024-01-09 10:11:11 +01:00
CODENOTIFY nix: update pnpm hash (#51512) 2023-05-05 12:51:59 +00:00
CONTRIBUTING.md Update marketing website link in monorepo (#58449) 2023-12-01 22:22:34 +00:00
deps.bzl Bump go-mockgen to include lenient type checking (#59397) 2024-01-08 21:20:24 +00:00
doc.go
docsite_run.sh Onboarding UI Fixes (#58788) 2023-12-07 14:27:16 +05:30
eslint-relative-formatter.js bazel: implement custom ESLint Bazel rule (#52062) 2023-05-22 04:05:45 -07:00
flake.lock nix: bump to bazel 7 (#59327) 2024-01-04 13:43:37 +00:00
flake.nix nix: upgrade node and pnpm (#58015) 2023-10-31 17:55:55 +02:00
gen.go Bump go-mockgen to include lenient type checking (#59397) 2024-01-08 21:20:24 +00:00
go.mod Bump go-mockgen to include lenient type checking (#59397) 2024-01-08 21:20:24 +00:00
go.sum Bump go-mockgen to include lenient type checking (#59397) 2024-01-08 21:20:24 +00:00
graphql-schema-linter.config.js
LICENSE relicense all paths other than MIT licensed code, client/cody*, jetbrains, VS code, and browser extension to enterprise (#53345) (#53345) 2023-06-13 10:28:11 -07:00
LICENSE.enterprise Update marketing website link in monorepo (#58449) 2023-12-01 22:22:34 +00:00
linter_deps.bzl build: add buildifier check to Aspect Workflows (#58566) 2023-11-27 14:58:01 +02:00
mockgen.temp.yaml externalAuthSignup: instrument with V2 events (#59036) 2023-12-15 23:19:29 +00:00
mockgen.test.yaml lib/managedservicesplatform: init MSP runtime, add lib/background from internal/goroutine (#57651) 2023-10-28 03:08:12 +00:00
mockgen.yaml mocks: Reorganize mock definitions into multiple files (#36967) 2022-06-27 20:59:16 +00:00
nogo_config.json grpc: example: tweak example package to show off new retry logic (#59218) 2023-12-22 16:20:49 -08:00
package.json svelte: Towards a better data fetching and GraphQL authoring experience (#59383) 2024-01-09 10:33:30 +01:00
pnpm-lock.yaml svelte: Towards a better data fetching and GraphQL authoring experience (#59383) 2024-01-09 10:33:30 +01:00
pnpm-workspace.yaml cody: development branch (#49761) 2023-03-23 20:41:11 +01:00
postcss.config.js extensibility: add featured extensions to registry (#21665) 2021-06-10 13:55:20 -04:00
prettier.config.js clean up Cody CSS to increase shareability and improve display in web app (#50279) 2023-04-03 12:29:05 -07:00
README.md Update marketing website link in monorepo (#58449) 2023-12-01 22:22:34 +00:00
renovate.json Require approval to run Renovate (#57608) 2023-10-18 20:36:53 +02:00
SECURITY.md
service-catalog.yaml lib/servicecatalog: init to distribute catalog (#46999) 2023-01-26 17:22:27 -08:00
sg.config.yaml Remove App from codebase (#59115) 2023-12-21 01:07:05 +01:00
sg.doctor.yaml sg: add doctor command to generate a diagnostics report (#58824) 2023-12-11 16:34:03 +00:00
shell.nix nix: bump to bazel 7 (#59327) 2024-01-04 13:43:37 +00:00
sonar-project.properties Use Buildkite to run Sonarcloud (#54875) 2023-07-21 12:16:03 -04:00
stamp_tags.bzl Switch to OCI/Wolfi based image (#52693) 2023-06-02 12:12:52 +02:00
tsconfig.base.json web: fix pnpm-lock issue (#47478) 2023-02-09 22:04:31 -08:00
tsconfig.json Vscode extension: Delete vscode extension package (#58023) 2023-10-31 18:39:30 -03:00
vitest.shared.ts code intel: Don't rely on URL polyfill to correctly parse git: URIs (#58258) 2023-11-17 19:32:46 +01:00
vitest.workspace.ts vitest: Fix workspace config wrt client/web/ (#58397) 2023-11-17 08:22:46 +00:00
WORKSPACE bazel: updates for hermetic_cc_toolchain + zig bump (#59333) 2024-01-08 17:07:57 +00:00

DocsContributingTwitterDiscord

Build status Scorecard Latest release Discord Contributors


Sourcegraph makes it easy to read, write, and fix code—even in big, complex codebases.

  • Code search: Search all of your repositories across all branches and all code hosts.
  • Code intelligence: Navigate code, find references, see code owners, trace history, and more.
  • Fix and refactor: Roll out large-scale changes to many repositories at once and track big migrations.

Getting started



Development

Refer to the Developing Sourcegraph guide to get started.

Documentation

The doc directory has additional documentation for developing and understanding Sourcegraph:

License

This repository contains primarily non-OSS-licensed files. See LICENSE.