Skip to content

Commit

Permalink
bugfixes, forwarding to nested LSP projects (#173)
Browse files Browse the repository at this point in the history
Co-authored-by: Jerel Miller <[email protected]>
  • Loading branch information
phryneas and jerelmiller authored Aug 22, 2024
1 parent 0a518b1 commit 415ff4a
Show file tree
Hide file tree
Showing 26 changed files with 1,622 additions and 530 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-clocks-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vscode-apollo": patch
---

Fix a bug where when rapidly changing multiple files some of the changes might have gotten lost.
12 changes: 12 additions & 0 deletions .changeset/plenty-radios-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"vscode-apollo": patch
---

Fixed a bug where hints on the 0-th line of an embedded GraphQL document were offset incorrectly.


E.g. in
```js
const veryLongVariableName = gql`type Foo { baaaaaar: String }`
```
the hover on `String` would only appear when hovering characters left of it.
5 changes: 4 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"${workspaceFolder}/sampleWorkspace/sampleWorkspace.code-workspace"
],
"sourceMaps": true,
"env": { "APOLLO_ENGINE_ENDPOINT": "http://localhost:7096/apollo" },
"env": {
"APOLLO_ENGINE_ENDPOINT": "http://localhost:7096/apollo",
"APOLLO_FEATURE_FLAGS": "rover"
},
"outFiles": ["${workspaceRoot}/lib/**/*.js"]
},
{
Expand Down
78 changes: 72 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,22 @@
"@wry/equality": "0.5.7",
"cosmiconfig": "9.0.0",
"dotenv": "16.4.5",
"fractional-indexing": "2.1.0",
"glob": "11.0.0",
"graphql": "16.9.0",
"graphql-language-service": "5.2.2",
"graphql-tag": "2.12.6",
"lodash.debounce": "4.0.8",
"lodash.merge": "4.6.2",
"lodash.throttle": "4.1.1",
"lz-string": "1.5.0",
"minimatch": "10.0.1",
"moment": "2.30.1",
"vscode-languageclient": "9.0.1",
"vscode-languageserver": "9.0.1",
"vscode-languageserver-textdocument": "1.0.12",
"vscode-uri": "3.0.8",
"which": "4.0.0",
"zod": "3.23.8",
"zod-validation-error": "3.3.1"
},
Expand All @@ -67,6 +70,7 @@
"@types/jest": "29.5.12",
"@types/lodash.debounce": "4.0.9",
"@types/lodash.merge": "4.6.9",
"@types/lodash.throttle": "^4.1.9",
"@types/node": "20.14.10",
"@types/vscode": "1.90.0",
"@typescript-eslint/eslint-plugin": "6.9.1",
Expand Down
3 changes: 2 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@types/vscode",
"@typescript-eslint/eslint-plugin",
"@typescript-eslint/parser",
"eslint"
"eslint",
"fractional-indexing"
]
}
3 changes: 3 additions & 0 deletions sampleWorkspace/localSchema/src/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ gql`
}
}
`;

// prettier-ignore
const verylonglala = gql`type Foo { baaaaaar: String }`
3 changes: 3 additions & 0 deletions sampleWorkspace/rover/apollo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
rover: {},
};
14 changes: 14 additions & 0 deletions sampleWorkspace/rover/src/test.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
The query type, represents all of the entry points into our object graph
"""
type Query {
me: User!
}

"""
Test
"""
type User {
id: ID!
name: String!
}
30 changes: 30 additions & 0 deletions sampleWorkspace/rover/src/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import gql from "graphql-tag";

sdfsdfs;
gql`
"""
The query type, represents all of the entry points into our object graph
"""
type Query {
me: User!
}
"""
Test
"""
type User {
id: ID!
name: String!
}
`;

console.log("foobar!");

gql`
type User {
lastName: String!
}
`;

// prettier-ignore
const verylonglala = gql`type Foo { baaaaaar: String }`
3 changes: 3 additions & 0 deletions sampleWorkspace/sampleWorkspace.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
},
{
"path": "localSchemaArray"
},
{
"path": "rover"
}
],
"settings": {}
Expand Down
29 changes: 19 additions & 10 deletions src/language-server/config/__tests__/loadConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,27 @@ Object {
}
`,
});

const config = await loadConfig({
configPath: dirPath,
});
expect(config?.rawConfig).toMatchInlineSnapshot(`
fs.mkdirSync(`${dir}/bin`);
fs.writeFileSync(`${dir}/bin/rover`, "", { mode: 0o755 });
let oldPath = process.env.PATH;
process.env.PATH = `${dir}/bin:${oldPath}`;
try {
const config = await loadConfig({
configPath: dirPath,
});
expect(config?.rawConfig).toMatchInlineSnapshot(`
Object {
"engine": Object {
"endpoint": "https://graphql.api.apollographql.com/api/graphql",
},
"rover": Object {},
"rover": Object {
"bin": "${dir}/bin/rover",
},
}
`);
} finally {
process.env.PATH = oldPath;
}
}));

it("[deprecated] loads config from package.json", async () => {
Expand Down Expand Up @@ -267,7 +276,7 @@ Object {
describe("env loading", () => {
it("finds .env in config path & parses for key", async () => {
writeFilesToDir(dir, {
"apollo.config.js": `module.exports = { client: { name: 'hello' } }`,
"apollo.config.js": `module.exports = { client: { } }`,
".env": `APOLLO_KEY=service:harambe:54378950jn`,
});

Expand All @@ -280,7 +289,7 @@ Object {

it("finds .env.local in config path & parses for key", async () => {
writeFilesToDir(dir, {
"apollo.config.js": `module.exports = { client: { name: 'hello' } }`,
"apollo.config.js": `module.exports = { client: { } }`,
".env.local": `APOLLO_KEY=service:harambe:54378950jn`,
});

Expand All @@ -293,7 +302,7 @@ Object {

it("finds .env and .env.local in config path & parses for key, preferring .env.local", async () => {
writeFilesToDir(dir, {
"apollo.config.js": `module.exports = { client: { name: 'hello' } }`,
"apollo.config.js": `module.exports = { client: { } }`,
".env": `APOLLO_KEY=service:hamato:54378950jn`,
".env.local": `APOLLO_KEY=service:yoshi:65489061ko`,
});
Expand Down Expand Up @@ -337,7 +346,7 @@ Object {
it("infers rover projects from config", () =>
withFeatureFlags("rover", async () => {
writeFilesToDir(dir, {
"apollo.config.js": `module.exports = { rover: {} }`,
"apollo.config.js": `module.exports = { rover: { bin: "/usr/bin/env" } }`,
});

const config = await loadConfig({
Expand Down
Loading

0 comments on commit 415ff4a

Please sign in to comment.