-
Notifications
You must be signed in to change notification settings - Fork 468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VSCode Plugin: Loading Schema Twice #801
Comments
This is where the error is coming from:
|
I currently have a configuration that looks like this: module.exports = {
client: {
includes: [
'./packages/original-series-engine/addon/**/*.graphql',
'./packages/original-series-engine/addon/**/*.js'
],
service: {
name: 'Original Series Workflow API',
localSchemaFile:
'./packages/original-series-engine/addon/graphql/schema.graphql'
}
}
}; The documentation seems to suggest that I could leave out my But in practice, that doesn't work, as I get a complaint that
If I provide a If I make |
were you able to find a solution to this @alexlafroscia? I'm running into the same issue |
Nope, unfortunately not. I've been flip-flopping between this and the Prisma VSCode plugin, because both have issues for me. I'm currently on the Prisma one, which is working a little better! |
I've been doing a lot of back and forth between those 2 as well. I think our issue might be solved with the next release based on this commit that documents our use case with service nested into client. It is tagged with Would you mind sharing what you have on your .graphqlconfig to get the Prima extension to work properly? |
Sure -- not that this is specific to our application in some ways, which is a monorepo of Ember packages {
"projects": {
"indie-engine": {
"schemaPath": "packages/indie-engine/addon/graphql/schema.graphql",
"includes": ["packages/indie-engine/addon/**/*.*"],
"excludes": [
"packages/indie-engine/addon/graphql/schema.graphql",
"packages/indie-engine/addon/graphql/fragments.js"
],
"extensions": {
"endpoints": {
"dev": "http://localhost:3001/api/workflow/graphql/",
"test": "http://localhost:4200/api/workflow/graphql/"
},
"generate-fragments": {
"output": "packages/indie-engine/addon/graphql/fragments.js",
"generator": "js"
}
}
},
"original-series-engine": {
"schemaPath": "packages/original-series-engine/addon/graphql/schema.graphql",
"includes": ["packages/original-series-engine/addon/**/*.*"],
"excludes": [
"packages/original-series-engine/addon/graphql/schema.graphql"
],
"extensions": {
"endpoints": {
"test": "http://localhost:4200/api/workflow/original-series/graphql"
}
}
},
"workflow-components": {
"schemaPath": "packages/workflow-components/tests/graphql/schema.graphql",
"includes": ["packages/workflow-components/addon/**/*.*"],
"extensions": {
"endpoints": {
"test": "http://localhost:4200/api/workflow/original-series/graphql"
}
}
}
}
} |
Thank you for sharing @alexlafroscia, this is def helpful |
Sorry we haven't responded to this until now! Has this issue been resolved in the past couple months? |
@Hotell Are you also getting the error for it trying to overwrite existing types or just the multiple loading notifications? |
@JakeDawkins I just installed the VSCode extension this morning and am seeing this issue. I am working around the error with module.exports = {
client: {
service: {
name: 'my-schema',
localSchemaFile: './src/schema.graphql',
},
// hack: remove .graphql from includes to avoid duplicate schema errors
includes: ['./src/**/*.{ts,js,tsx}'],
},
} but I think this has the effect of disabling the language features when editing the schema itself. They work great from the Edit: I thought maybe this was unique to |
@benmosher @alexlafroscia It looks like both of your issues are from the language server trying to load the schema from A Workaround for this would be to do one of the following
A more permanent fix would be to track the URIs of the loaded schema files to make sure there's no accidental reload, but I'll have to look into that. I'm not sure how much extra work would be required yet. |
Also, quick note, we don't fully support editing schema files right now. So things like typeahead and type information in schema files loaded by |
Nice! Explicitly excluding the local schema in |
I am getting this issue whenever I open a file diff that contains typeDefs from the source control sidebar |
That's really inconvenient and renders the plugin useless for me.
|
I'm sorry you're still seeing this @DanielHabenicht. I'm not sure what's going on. Is there a repo you can point me to with the reproduction of this? Does your monorepo have multiple apollo projects inside it? If so, having a single apollo config at the root of the repo won't work. Config files only support single projects. Maybe you could also paste in your config here to help me figure out what's going on. |
FWIW I'm seeing this same issue loading a project that gets the schema from an endpoint URL instead of module.exports = {
client: {
service: {
name: "feature-keeper-api",
endpoint: {
url: "http://localhost:8000/.netlify/functions/graphql",
},
},
includes: ["./src/**/*.{ts,tsx}"],
excludes: [
"./src/**/.test.{ts,tsx}",
"./src/@types",
"./src/functions",
"**/*.graphql",
],
},
} I also see the error running EDIT: Tried changing the service: {
name: "feature-keeper-api",
localSchemaFile: "./schema/api.graphql",
}, but I'm still seeing the same issue. The repo where I'm having the issue is private but I'm happy to share it with an apollo dev if it would help troubleshoot this issue. Let me know. EDIT: I tried removing all I think I figured out my problem. One of my excludes ( |
This was fixed for me by adding excludes. From: module.exports = {
client: {
service: {
name: 'api',
url: 'http://localhost:4000/'
}
}
} to: module.exports = {
client: {
service: {
name: 'api',
url: 'http://localhost:4000/'
},
excludes: ['**/*.graphql']
}
} |
@JakeDawkins I have been struggling with the same problem as well. Adding excludes did not solve the problem for me (may be because I am using the registry?) I am using the Apollo Schema Registry with Apollo Federation My apollo.config.js looks like this:
Screenshot of the error in vscode apollo graphql extension: The VSCode extension keeps restarting again and again for 5 times and then it says the server will not be restarted (screenshot below). Then I have to restart the window again to get it back up. Suggestions work until it crashes. This is the version of libraries I am using:
Also, I see Apollo GraphQL listed twice in the Outputs section of VSCode (similar to what is mentioned here: #690 (comment)) - Is it loading once for registry and once for local graphql files? Thanks in advance. |
Finally got it solved. It was because I was writing my code in Typescript in src (.ts) and it was getting built to javascript in dist (.js) and Apollo GQL was going through both of these causing the duplication. I added |
So weird that the issue is still not resolved |
Im having this issue as well. I tried most combinations in apollo.config.js. I finally got it to work, I'm not sure how it finds all the schema definitions but I have an isomorphic react app, so the way I solved it was to only include files under the client directory, excluding all server files. |
@niclaspallin the current config setup only really allows for a single project per apollo config file. so if you have a service and a client project under a single apollo.config glob, it makes sense why this error would be happening for you. |
@JakeDawkins Doing this generates the following error for me: My serverside schema is defined in module.exports = {
client: {
excludes: ['src/**/*.gql'],
service: {
name: 'local',
url: 'http://localhost:port/graphql',
},
},
}; So if I exclude the files I get nothing from the language server (no jump to definition, no autocomplete) and if I remove the service definition I get the above error. |
i am also shocked by the current state of the vscode extension. It sometimes work, and when it works its fantastic, but as soon as it gets a bit more complicated like having a project that requires two graphql endpoints, it fails and in a very weird and inconsistent way. I tried to configure two apollo.config.js, but that leads to strange hard to reproduce errors. Also just having one apollo.config.js and adding excludes to ignore queries that use the other graphql endpoint does not work at all. excludes seem to have no effect at all. I think this needs a major overhowl and maybe the maintainers need to dog-feed it to themselves (in particular the multi-endpoint use-case). If the core team cannot maintain it, it would be fair for the community that this is announced accordingly. |
Related hasura/graphql-engine#6466 |
Realizing I forgot to come back to close this! This was fixed and released a while ago in apollographql/vscode-graphql#8. If you're still seeing this error please open a new issue over on the new repo! Thanks for all the help investigating 😄 |
It seems like the schema is being loaded twice by the VSCode plugin. As soon as I load the plugin, I get the following error:
This is the first type in my schema, and is only defined once in the file. This is leading me to think that the file is attempting to be loaded more than once, adding to the existing schema and causing the error.
The text was updated successfully, but these errors were encountered: