apollographql / apollographql/vscode-graphql

Work with multiple projects and/or support GraphQL Config

Open
#247 9 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
78
Forks
23
PR merge metrics
No merged PRs in 30d

Description

In our project, we're working with multiple different graphs.
Sometimes these graphs are actually external services we do not control but we write queries to target them.
We've been using [VS Code GraphQL: Language Feature Support](https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql) extension for GraphQL LSP

I've been setting up GraphQL Config https://the-guild.dev/graphql/config to tell the VS Code extension which files should use which schema

Here's the config we are currently using

graphql.config.js

```js
const mxSchema = "backend/packages/graphql-schema/schema.gen.graphql";

module.exports = {
projects: {
default: {
schema: mxSchema,
},
"backend-tests": {
schema: mxSchema,
documents: ["backend/api/src/**/__tests__/**/*.spec.ts"],
},
"server-rendering": {
schema: mxSchema,
documents: [
"backend/server-rendering/src/graphql/**/*!(.gen).{ts,tsx}",
"backend/server-rendering/src/modules/**/graphql/**/*!(.gen).{ts,tsx}",
],
},
"work-order-asset-snapshots": {
schema: mxSchema,
documents: ["backend/graphql/src/mutations/helpers/workOrderAssetSnapshot/**/*.{ts,tsx}"],
},
frontend: {
schema: mxSchema,
documents: [
"frontend/src/**/*.gql!(.gen).{ts,tsx}",
"frontend/src/graphql/**/*!(.gen).{ts,tsx}",
"frontend/src/modules/**/graphql/**/*!(.gen).{ts,tsx}",
"native/src/shared-all/graphql/**/*!(.gen).{ts,tsx}",
"native/src/shared-clients/graphql/**/*!(.gen).{ts,tsx}",
],
},
dashboard: {
schema: mxSchema,
documents: [
"dashboard/src/**/*.gql!(.gen).{ts,tsx}",
"dashboard/src/graphql/**/*!(.gen).{ts,tsx}",
"dashboard/src/modules/**/graphql/**/*!(.gen).{ts,tsx}",
"native/src/shared-all/graphql/**/*!(.gen).{ts,tsx}",
"native/src/shared-clients/graphql/**/*!(.gen).{ts,tsx}",
],
},
native: {
schema: mxSchema,
documents: [
"native/src/**/*.gql!(.gen).{ts,tsx}",
"native/src/graphql/**/*!(.gen).{ts,tsx}",
"native/src/modules/**/graphql/**/*!(.gen).{ts,tsx}",
"native/src/shared-all/graphql/**/*!(.gen).{ts,tsx}",
"native/src/shared-clients/graphql/**/*!(.gen).{ts,tsx}",
],
},
gpl: {
schema: "gql-gen/gpl.gen.graphql",
documents: "backend/common/src/core/gpl/*!(.gen).ts",
},
metal: {
schema: "backend/node_modules/@metal/graphql/schema.gen.graphql",
documents: "backend/common/src/core/metal/*!(.gen).ts",
},
},
};
```

You'll notice that we have multiple "client" applications targeting the same schema which allows to better understand which fragments belongs to which project.
Also at the end you'll notice that have a local copy of the `gpl` project that is an external api we call and the `metal` project has an sdk providing the schema that we're using as well.

Worth noting that we have a separate config for GraphQL Codegen, because the VS Code GraphQL LSP extension doesn't support multiple schema files even though the GraphQL Config standard supports it. So we stitch all our schemas into 1 big schema file and pipe this into the extension instead

Since we are starting to look into Federation, we are investigating better extension to empower our devs and was hoping Apollo's extension would support the GraphQL Config for a more standardized way to provide a great GraphQL experience to our developpers.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the extension's current schema and document configuration, then compare it with the GraphQL Config projects example in the issue. Done should mean the extension can identify multiple projects, associate documents with their configured schemas, and support external schema files without requiring one stitched schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.