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
[graphql-lsp] Template string fragment get Unknown fragment
error
#3066
Comments
The related issue: |
there must have been a change that broke this use case. it works if the fragments are in a separate file, or are defined in the same graphql string, which is what the tests cover |
@VinceBT-BG here is the config: export default {
schema: "src/schema/schema.graphql",
documents: "src/queries/**/*.ts",
}; and a very simple schema for testing purposes: # for example
type ExampleType {
shelter: String
something: String
however: String
}
type Query {
exampleField: ExampleType
love: String
message: String
} the syntax highlighting isn't relevant here to be clear, this is a bug you're having with the LSP server, but what I'm guessing is that the |
I was indeed using EDIT: Indeed when using |
@VinceBT-BG music to my ears! another happy user. I will add something to the FAQ section for users using legacy awesome gif tool by the way, i like the keyboard icons, maybe I will use this! |
fragment file: import { gql } from '@sb/webapp-api-client/graphql';
export const processTestItemListQuery = gql(/* GraphQL */ `
query processTestItemListQuery {
allProcessTestItems(first: 100) {
edges {
node {
...processTestItemListItemFragment
}
}
}
}
`);
export const processTestItemListItemDeleteMutation = gql(/* GraphQL */ `
mutation processTestItemListItemDeleteMutation($input: DeleteProcessTestItemMutationInput!) {
deleteProcessTestItem(input: $input) {
deletedIds
}
}
`);
export const processTestItemListItemFragment = gql(/* GraphQL */ `
fragment processTestItemListItemFragment on ProcessTestItemType {
id
name
price
}
`); .graphqlconfig: {
"name": "Untitled GraphQL Schema",
"projects": {
"api": {
"name": "GraphQL API",
"schema": "packages/webapp-libs/webapp-api-client/graphql/schema/api.graphql"
},
"contentful": {
"name": "Contentful API",
"schema": "packages/webapp-libs/webapp-contentful/graphql/schema/contentful.graphql"
}
},
"documents": "**/*.ts"
} |
@acao I still have same issue now. Should I create new issue or could you reopen this issue? 🙏 |
@ypresto can you open a new issue, and please provide the config? if it's a multi project config then it's a different bug with the same message |
Adding "documents" to my config file worked, thanks! |
Unknown fragment
errorUnknown fragment
error
I am still facing this issue in my vscode. Here is my graphql-config: { My fragment is defined in another file. Q: Is there any solution for this? VSCode version: 1.86.2 |
@sachingaikwad123 can you see if the pre-release in #3521 fixes the issue? we have tests that I think should confirm this issue is resolved. what I discovered was we were updating the fragment cache for onUpdate and onWatchedFilesUpdate, but not on onOpenOrAdd, and some other issues with fragment cache keys that piled up along the way. now we have an integration test suite for the server that confirms a happy path for validating fragments and fragments on queries across changes to all files. i will double check to make sure we are still confirming validation is empty where it should be on every mutative event |
hey! having the same issue as @sachingaikwad123 @acao I switched to the pre-release and now the option also, the go to fragment definition is working partially, it's opening the file where the fragment but the cursos do not go the the definition line. |
The only thing i want to clarify here with the incoming fix is that we are not inferring information from template string expressions. If a fragment is present in any file in the project, it can be used in any query, and it's up to the client framework to decide how to resolve fragments |
When inserting a fragment inside a template string, the fragment does not get recognized when it gets called in the rest of the gql string
IDE: VSCode
1.75.1
Extensions:
v0.8.5
v1.0.6
The text was updated successfully, but these errors were encountered: