apollographql / vscode-graphql Goto Github PK
View Code? Open in Web Editor NEWApollo GraphQL VS Code extension
Home Page: https://marketplace.visualstudio.com/items?itemName=apollographql.vscode-apollo
License: MIT License
Apollo GraphQL VS Code extension
Home Page: https://marketplace.visualstudio.com/items?itemName=apollographql.vscode-apollo
License: MIT License
in vite version 3 package.json type:"module" and when i create apollo.config.js and add module.export = {...} dont complie and show error change type to commonjs or cjs and I change file name to apollo.config.cjs don't work and when change type to commonjs, vite don't work please fix this problem
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
Renovate tried to run on this repository, but found these problems.
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
These updates are pending. To force PRs open, click the checkbox below.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@changesets/changelog-github
, @changesets/cli
, @graphql-codegen/cli
, @graphql-codegen/typescript-operations
, @types/node
, @typescript-eslint/eslint-plugin
, @typescript-eslint/parser
, eslint
, eslint-config-prettier
, eslint-plugin-prettier
, memfs
, prettier
, typescript
, vsce
)@apollo/federation
, apollo-datasource
)@graphql-codegen/cli
, @graphql-codegen/typescript-operations
, @types/cosmiconfig
, @types/glob
, @types/node
, @typescript-eslint/eslint-plugin
, @typescript-eslint/parser
, eslint
, memfs
, rimraf
, typescript
, vsce
)apollo-datasource
, apollo-server-errors
)4
/4
CVEs have Renovate fixes.
package.json
minimatch
- GHSA-f8q6-p94x-37v3 (fixed in 3.0.5)
moment
- GHSA-wc69-rhjr-hc9g (fixed in 2.29.4)
- GHSA-8hfj-j24r-96c4 (fixed in 2.29.2)
node-fetch
- GHSA-r683-j2x4-v87g (fixed in 2.6.7)
.circleci/config.yml
secops 2.0.7
cimg/node 21.6.2
.github/workflows/release.yml
actions/checkout v4
andstor/file-existence-action v2.0.0
actions/setup-node v3
changesets/action v1
HaaLeo/publish-vscode-extension v1
slackapi/slack-github-action v1.24.0
package.json
@apollo/federation ^0.23.1
@endemolshinegroup/cosmiconfig-typescript-loader ^1.0.0
@types/lz-string ^1.3.34
@types/node-fetch 2.6.11
apollo-datasource ^0.8.0
apollo-link ^1.2.3
apollo-link-context ^1.0.9
apollo-link-error ^1.1.1
apollo-link-http ^1.5.5
apollo-server-errors ^2.0.2
await-to-js ^3.0.0
codemirror ^5.63.3
core-js ^3.0.1
cosmiconfig ^5.0.6
dotenv ^16.0.0
glob ^7.1.3
graphql ^15.5.0
graphql-language-service-interface ^2.8.4
graphql-tag ^2.10.1
lodash.debounce ^4.0.8
lodash.merge ^4.6.1
lz-string ^1.4.4
minimatch ^3.0.4
moment ^2.29.1
node-fetch ^2.2.0
query-string ^7.0.1
resolve-from ^5.0.0
sha.js ^2.4.11
vscode-languageclient ^5.2.1
vscode-languageserver ^5.1.0
vscode-uri 3.0.8
@changesets/changelog-github 0.4.8
@changesets/cli 2.26.2
@graphql-codegen/cli 2.2.0
@graphql-codegen/typescript-operations 2.1.3
@types/cosmiconfig 5.0.3
@types/glob 7.2.0
@types/jest 29.5.12
@types/lodash.debounce 4.0.9
@types/lodash.merge 4.6.9
@types/node 14.17.6
@types/node-fetch 2.6.11
@typescript-eslint/eslint-plugin 6.9.1
@typescript-eslint/parser 6.9.1
eslint 8.52.0
eslint-config-prettier 9.0.0
eslint-plugin-prettier 5.0.1
jest 29.7.0
jest-environment-node 29.7.0
memfs 3.2.2
prettier 3.0.3
rimraf 3.0.2
ts-jest 29.1.2
typescript 4.3.5
vsce 1.96.1
vscode 1.1.37
vscode ^1.30.0
.nvmrc
node v20
If i extend types in my client-only schema, I get the above errors.
After some investigation, I found out that this actually only happens when reading the schema from a localhost URL like:
service: {
name: <some-name>,
url: 'http://localhost:3000/graphql',
skipSSLValidation: true,
},
When looking at my server, it actually does not look like the local URL is being used at all?
graphql-code-generator is a widely used tooling that provides types generation from.graphql
/.gql
schema files, it can also automatically generate hooks to be used in a React + Typescript environment.
Graphql Queries/Mutations/Subscriptions can be defined inside a folde that the code generator then uses to build custom React hooks that wrap the query in a gql literal string tag.
For example:
Given this query:
query GetCurrentUser {
currentUser {
id
}
}
You get the following output:
export const GetCurrentUserDocument = gql`
query GetCurrentUser {
currentUser {
id
}
}
`;
The issue starts when Apollo Plugin attempts to parse this generated query. Since the project already has another query with the same name, as it was copied directly from the original definition, The Apollo Plugin crashes due to duplicated query names.
Add the option to ignore files matching a certain pattern (Eg: src/__auto_generated__/**
, src/hooks/GeneratedHooks/**
).
This issue has been reported before and can be found here on the old repo: apollographql/apollo-tooling#2064
Could be related to: #40
//apollo.config.cjs
module.exports = {
client: {
service: {
name: 'backend',
url: 'http://localhost:5555/graphql',
}
}
}
//codegent.ts
import type { CodegenConfig } from '@graphql-codegen/cli'
const config: CodegenConfig = {
overwrite: true,
schema: 'http://localhost:5555/graphql',
documents: ['src/**/*.{ts,tsx}'],
ignoreNoDocuments: true,
watch: true,
generates: {
'./src/00-shared/graphql/codegen.graphql.tsx': {
plugins: [
'typescript',
'typescript-operations',
'typescript-react-apollo',
],
config: {
withComponent: true,
},
},
},
}
export default config
how do I exclude the file that is generated by codegen - to fix the error?
Currently we are looking to connect our API testing (VSCode IDE) to the graph schema, but we are unclear how to determine the variant for a selected environment. Is variant switching possible?
Currently we are using oauth2, Router (just moved from gateway), and subgraphs against different variants.
Performance
vscode-apollo
1.19.7
Windows_NT x64 10.0.19043
1.61.2
c:\Users\Admin\AppData\Local\Temp\apollographql.vscode-apollo-unresponsive.cpuprofile.txt
Find more details here: https://github.com/microsoft/vscode/wiki/Explain-extension-causes-high-cpu-load
Having issues getting VSCode extension (apollographql.vscode-apollo) to find my graphql file. Am I missing some configuration?
apollo.config.cjs file:
module.exports = {
client: {
service: {
name: "default",
localSchemaFile: './src/schema.graphql'
},
},
};
folder structure:
- src/
- schema.graphql
- apollo.config.cjs
Hey there, we could add a list of issues of the old repo to keep track off.
People maintaining can move the issues here:
when i have
const myQuery = gql`
query Wow {
whatever {
id
}
}
then autocomplete works, and syntax highlight works, so i could go under id
and type la
and id get a label
suggestion.
but with
const myQuery = gql(`
query Wow {
whatever {
id
}
}
`)
which unfortunately is required for typescript and codegen to work, now autocomplete and syntax highlight doesnt work!
can you fix is so that with parens, both autocomplete and syntax highlight works?
Hey! Would it be possible to publish this extension to OpenVSX? I'm trying to use the extension on GitPod but that doesn't support the Microsoft VisualStudio Marketplace.
Docs: Eclipse or their CI bot - alternative, might be easier for you (automatically publishes open source extensions to OpenVSX)
Currently, the repo name is vscode-graphql and the package.json name is "vscode-apollo". It is currently published to npm as vscode-apollo
though I'm not sure why it's published there at all. The extension ID is apollographql.vscode-apollo
and tht tiel is Apollo GraphQL
. vscode-graphql
does not exist in npm but there is another repository by that name which is a separate project: https://github.com/graphql/vscode-graphql
It would be a bit less confusing if these aligned a bit more; I think changing the GitHub repo name to vscode-apollo would be the simplest change.
Hi!
I've tried to use this extension on my project. The syntax highlighting seems to work fine on .ts files, but it doesn't work on .vue files. Moreover, I noticed that autocompletion works. I'm using the Volar 3 extension for vue. How may I solve this issue?
It might be related to No autocompletion and hover information in gql documents in Vue SFC but autocompletion and hover information is working to me; only syntax highlighting seems not to work
In my project, I use an endpoint for my graphql queries and use a schema written in a local file within the project to extend some types, so that I can fetch those fields by resolving them locally through the @client directive. I can’t configure the apollo.config.js file to merge the remote schema with the local one, so for VS Code those fields resolved locally don’t exist. How can I solve this problem?
P.S. The queries are executed correctly by resolving all fields, both those resolved by the remote schema and those resolved locally, only VS Code returns an error.
Hi,
I have a React application and I use ViteJs as a Front End Tooling.
My application is configured through .env files: in these files I also put the url to the GraphQl service (backend).
How can I read the GraphQl service url from .env files and properly setup apollo.config.js
file?
Is it possible?
Could you please provide an example?
Many thanks in advance,
Mauro
Performance
vscode-apollo
1.19.4
Windows_NT x64 10.0.19043
1.58.2
c:\Users\Mariela\AppData\Local\Temp\apollographql.vscode-apollo-unresponsive.cpuprofile.txt
Find more details here: https://github.com/microsoft/vscode/wiki/Explain-extension-causes-high-cpu-load
Previous: apollographql/apollo-tooling#821
If you're using a tool such as nrwl/nx where you have entry points in the "app" folder and libraries in a "libs" folder, it's not possible to configure this plugin to search in anywhere other than the "src" folder.
For various reasons, I have a couple operations in my project that are duplicated that I don't want to/can't move to a single file and export. Because of this I end up getting the "multiple definitions for the operation" error until the extension eventually stops and I can't use it any more. Is there any interest in allowing multiple definitions, either by default or as a preference?
Hi,
I have a problem while adding the extension with the local schema file.
We are using aws-app-sync. Below is the example schema
Type Article{
title:String!
description:String
author:Author
}
type Subscription {
updateTitleSubscription(domain: String!): Article
@aws_subscribe(mutations: ["updateTitle"])
}
my apollo.config.js
module.exports = {
client: {
includes: [
'./src/**/stores/**/*.js',
'./src/**/stores/**/*.ts',
'./src/**/stores/**/*.tsx'
],
service: {
localSchemaFile: './src/graphql/schema.graphql'
}
}
}
Is there a way to add custom decorators like above or shall i remove them to work?
TIA 😃
Performance
vscode-apollo
1.19.9
Windows_NT x64 10.0.19044
1.62.2
c:\Users\Admin\AppData\Local\Temp\apollographql.vscode-apollo-unresponsive.cpuprofile.txt
Find more details here: https://github.com/microsoft/vscode/wiki/Explain-extension-causes-high-cpu-load
implements
and @key
properties.On the Visual Studio Marketplace page for this extension the Issues and Repository links should be changed to https://github.com/apollographql/vscode-graphql/issues and https://github.com/apollographql/vscode-graphql .
how to make apollo.config.js support esm project type:module
can apollo-tooling support apollo.config.cjs, apollo.config.mjs?
We have a generated schema file, schema.graphql
. The file is generated by merging definitions from gql
tags throughout our typescript backend.
We would like to get intellisense, autocomplete, etc. within those gql
tags in our typescript backend files. In order to do that, it seems like we must include those files in our apollo.config.js
via the includes
key. But if we do this, the language server repeatedly crashes with a ton of errors along these lines: Type "XXX" already exists in the schema. It cannot also be defined...
. For reference, here is our config, roughly:
module.exports = {
client: {
service: {
name: "service-name",
localSchemaFile: "./generated/schema.graphql",
},
includes: [
"./src/client/**/*.{ts,tsx,js,jsx}",
// If we include these server files, everything breaks
"./src/server/**/*.{ts,tsx,js,jsx}"
],
excludes: [
"**/*tests.{ts,tsx,js,jsx}",
"*.graphql",
],
},
};
Ideally we would either 1) have the schema parsed from our ts
files without loading the generated schema, or 2) be able to use intellisense for our ts
files without merging them into the loaded schema.
Example use case:
Next.js app where the API routes can call the graphql API as admins vs the frontend that can call the API as authenticated users.
Example config from graphql-code-generator config which allows a similar behaviour:
module.exports = {
generates: {
'./types/codegen/index.ts': {
schema: [
{
[`https${process.env.NEXT_PUBLIC_API_URL}`]: {
headers: {
'X-Hasura-Admin-Secret': XXXXXX,
'X-Hasura-Role': 'User',
},
},
},
],
documents: [
'./pages/**/*.tsx',
'./components/**/*.tsx',
'./utils/**/*.tsx',
],
},
'./types/codegen/admin-generated.ts': {
schema: [
{
[`https${process.env.NEXT_PUBLIC_API_URL}`]: {
headers: {
'X-Hasura-Admin-Secret': XXXXXX,
'X-Hasura-Role': 'Admin',
},
},
},
],
documents: ['./pages/api/**/*.ts'],
},
},
};
I'm very new with this stuff. I opened vs code as code .
in project folder. This two files in project root. when I click on config - schema realoads, when i click on client file - nothing happens, and plugin dont work.
I've reinstall plugin twice, cleaned ~/.vscode folder. Nothing works.
Hello,
When behind a corporate proxy, the extensions fails at startup with this error message:
[Network Error]: FetchError: request to https://graphql.api.apollographql.com/api/graphql failed, reason: connect ETIMEDOUT
ApolloError: request to https://graphql.api.apollographql.com/api/graphql failed, reason: connect ETIMEDOUT
Same project works just fine when not behind the proxy.
Things I've tried:
Looking at the code, I couldn't find any evidence of proxies being supported, libraries like https-proxy-agent
or global-agent
are not being used.
The only way I could get the proxy to work was by hacking direct access to my proxy in src/env/fetch/fetch.ts
:
const agent = new (HttpsProxyAgent as any)("http://proxy.company.com:8080");
function proxyFetch(url: RequestInfo, options: RequestInit | undefined) {
return fetch(url, {
...options,
agent,
});
}
export { proxyFetch as fetch };
export {
Request,
Response,
Headers,
ResponseInit,
BodyInit,
RequestInfo,
HeadersInit,
Body,
RequestInit,
RequestMode,
RequestCredentials,
RequestCache,
RequestRedirect,
} from "node-fetch";
Once I've done that, then the Apollo GraphQL status shows the schema as loaded.
Is there a setting, in vscode, the extension or in my environment that I am missing in order to use the extension behind a corporate proxy, or is it simply not supported?
I currently work with a multi-folder monorepo with a dedicated folder for all the configs.
root
|_ configs
|_ apollo.config.js
|_ frontend-project-1
|_source files
|_ frontend-project-2
|_source files
I open separate workspaces in vscode for project-1 and project-2 instead of pointing to the repo's root.
From what I see in the docs, the extension will not work if apollo.config.js
isn't present in the workspace repo (frontend-project-1
or frontend-project-2
), but I don't want to duplicate the config files in all the subfolders.
Is there any way I can provide a custom path for the config file for each subproject I import in my workspace?
┆Issue is synchronized with this Jira Task by Unito
┆Link To Issue: https://apollographql.atlassian.net/browse/NEBULA-1867
While in one of the Summit Day 0 workshops (the PM Federation Workshop - ask Mike if he can answer a question about recursion 😉) I noticed command+/ wasn't toggling the comments in a gql
tagged template.
FWIW, I tried with the GraphQL: Language Feature Support
extension and it works as expected; I cloned this repo to "develop" the extension locally, and copying the configuration from graphql.js.json
to this extension's corresponding graphql.js.json
makes it work, but there are a bunch of differences between the configs so I don't know which part addresses the issue ¯_(ツ)_/¯ Happy to open a PR anyways, if that's helpful!
Instead of apollo's gql
function, I use a generated gql
for TypeScript support like this
import { gql } from '__generated__'
const MY_QUERY = gql(/* GraphQL */ `
...myQuery
`)
Is it possible to integrate this extension to support this?
On both projects NuxtJS or NextJS I've got following error when I try to execute query
Error: graphql operation failed t: GraphQL Config file is not available in the provided config directory: <directory> Please check the config directory.
and provided by error directory has config and it's normally loaded when I check VSCode output.
✅ Service Loaded!
🆔 Service ID: NextJS-blog
🏷️ Schema Tag: current
`apollo.config.js` file
```js
module.exports = {
client: {
service: {
name: "NextJS-blog",
url: "http://api.spacex.land/graphql",
},
includes: ["**/*.tsx", "**/*.ts"],
},
}I'm on MacOS Montenery, Apple M1
With the latest update paren support was added (which is a change I love and helps a ton btw), and now it's triggering in the generated example comment from @graphql-codegen.
Is this expected? I do actually need to add a user field, so I can make this go away, but this extension probably shouldn't trigger in comments (or at least not comments in generated code).
Hi there,
when I try to reload my schema, it crashes with an error.
Error is showing up every time.
Same error is popping up when I click on the Apollo button on the bottom bar
Might be related to #64 as I sometimes see the same message in output console.
Apollo Graphql v1.19.11
VSCode info:
Version : 1.71.2
Validation : 74b1f979648cc44d385a2286793c226e611f59e7
Date : 2022-09-14T21:12:14.256Z
Electron : 19.0.12
Chromium : 102.0.5005.167
Node.js : 16.14.2
V8 : 10.2.154.15-electron.0
Système d’exploitation : Linux x64 5.15.0-47-generic snap
Sandboxé : No
Thanks!
Type: Bug
Let's say you have several projects in your workspace using apollo.config.js.
If none of them is in first position, the plugin is disabled and you'll have errors spawning about loading schemas and initializing Apollo GraphQL projects.
But as soon as you place one of the apollo projects in first place, the plugin is re-enabled.
Extension version: 1.19.11
VS Code version: Code 1.74.2 (e8a3071ea4344d9d48ef8a4df2c097372b0c5161, 2022-12-20T10:32:21.587Z)
OS version: Darwin arm64 22.2.0
Modes:
Sandboxed: No
Item | Value |
---|---|
CPUs | Apple M1 (8 x 24) |
GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled metal: disabled_off multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_renderer: enabled_on video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off |
Load (avg) | 4, 3, 3 |
Memory (System) | 16.00GB (0.05GB free) |
Process Argv | --crash-reporter-id 53a2c80b-8303-4272-b837-bc49d98b344e |
Screen Reader | yes |
VM | 0% |
I see a lot of failures in the Apollo GraphQL Output for vscode, that looks like this:
[Error - 18:28:53] Notification handler 'workspace/didChangeWatchedFiles' failed with message: ️️There are multiple definitions for the `OperationName` operation. Please rename or remove all operations with the duplicated name before continuing.When I search for this operation, I don't find it anymore.
Restarting vscode helps, but not for a long time.
Can we please have in this error actual places where it finds the problems?
That would help to understand the issue more, and actually help immensely when this problem actually occur.
Thank you!
Receiving this after the latest VSCode update. Anyone with the same error?
/.vscode/extensions/apollographql.vscode-apollo-1.19.9/lib/language-server/errors/validation.js:103
selectsClientFieldSet = Boolean(clientFields && clientFields.includes(fieldDef.name));
^
TypeError: Cannot read properties of undefined (reading 'name')
Hello,
While working on Ruby on Rails project, I noticed that the highlighting in the spec files is somehow wrong when using heredocs for GraphQL. It seems that after the first GraphQL heredoc, everything goes in yellow, the formatting while writing and the autocomplete doesn't work. I'm attaching a screenshot.
Example:
# foo_spec.rb
require 'rails_helper'
module Graph
module Mutations
describe FooMutation do
it 'flags foo' do
foo = create :foo
resolve <<~GRAPHQL, id: foo.id, flag: true
mutation($id: ID!, $flag: Boolean!) {
flagFoo(input: {id: $id, flag: $flag}) {
foo {
flagged
}
}
}
GRAPHQL
response_data.should eq 'flagFoo' => {'foo' => {'flagged' => true}]}
end
it 'unflags foo' do
foo = create :foo
resolve <<~GRAPHQL, id: foo.id, flag: false
mutation($id: ID!, $flag: Boolean!) {
flagFoo(input: {id: $id, flag: $flag}) {
foo {
flagged
}
}
}
GRAPHQL
response_data.should eq 'flagFoo' => {'foo' => {'flagged' => false}}
end
end
end
end
In our repo https://github.com/CMSgov/easi-app, we have a client project with a local schema file, with this apollo.config.js. When pkg/graph/schema.graphql
is open, the Go to Definition action doesn't work on types defined in the schema; it shows "No definition found", even for types that are definitely defined in the schema file.
With the apollographql.trace.server
setting on verbose
, the following messages are displayed - it looks like the language server isn't returning any responses for textDocument/definition
requests.
[Trace - 9:44:21 AM] Sending request 'textDocument/definition - (14)'.
Params: {
"textDocument": {
"uri": "file:///home/dylan/source/repos/easi-app/pkg/graph/schema.graphql"
},
"position": {
"line": 1095,
"character": 53
}
}
[Trace - 9:44:21 AM] Received response 'textDocument/definition - (14)' in 1ms.
No result returned.
Hello 👋 ,
thanks for your work :)
my vscode is yelling at me because i got some fields that are input and deprecated....
although it's supported in graphql-js now (graphql/graphql-js#2855)
i wonder if there's a way to support that :)
Regards
Please make the VSCode plug-in compatible with https://vscode.dev and https://github.dev.
More info:
Currently, the VSCode plugin only loads the GraphQL schema on startup and when explicitly requested to reload via the Apollo: Reload Schema
command.
An outdated schema can cause confusing GraphQL: Validation
problems. It would be great if reloading the schema was presented as a "Quick fix" for these problems!
(It also would be nice if the schema was periodically reloaded, but that's an orthogonal issue, since you might still want to disable automatic reloads or something.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.