graphql / graphiql

GraphiQL & the GraphQL LSP Reference Ecosystem for building browser & IDE tools.
MIT License
16.09k stars 1.72k forks source link

[graphiql] Fragment variables not supported #3568

Open gerdemb opened 7 months ago

gerdemb commented 7 months ago

Is there an existing issue for this?

Current Behavior

  fragment Fragment on AccountsConnection {
    nodes {
      id
      name
      balance(endDate: $date) {
        number
        currency
      }
    }
  }

  # ERROR Variable "$date" is never used in operation "Accounts".GraphQL: Validation
  query Accounts($startsWith: String!, $date: Date = "2024-03-24") {
    accounts(filter: { name: { startsWith: $startsWith } }, orderBy: NAME_ASC) {
      ...Fragment
    }
  }

Has flag this validation error on the Account query: Variable "$date" is never used in operation "Accounts".GraphQL: Validation. Actual code works as expected.

graphql.config.js

const config = {
  schema: "http://ds720.local:3000/graphql",
  documents: ["app/**/*.tsx"],
};

Using VSIX release found here: https://github.com/graphql/graphiql/pull/3521

Expected Behavior

Doesn't show validation error.

Steps To Reproduce

No response

Environment

Anything else?

No response

acao commented 7 months ago

this just means we need to update graphql, or we need to re-use the version in the project if it's available. these rulesets are entirely determined by the graphql version the LSP is shipping with currently

gerdemb commented 7 months ago

I am having this problem only intermittently so I suspect it may be something wrong with my development environment. Feel free to close this issue if you think it's not related to this package.

acao commented 7 months ago

Thank you! It still may be a problem on our end if I'm incorrect, so I'm going to keep this open until I have time to add tests to confirm that it works as it should, and fix the bug if not

acao commented 6 months ago

it appears we're still bundling with the latest version of graphql, so perhaps the latest specifiedRules still need to be updated to make this the default? these are what we use as the default rules for validation, and then the custom validation rules can be specified. if there is something we need to override to make this possible we can - for example, replacing the rule i linked to with another that supports fragment variables, or whatever path they chose to implement this spec