Skip to content
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

[lsp-server] Support go to definition for implementation first graphql setups #3558

Closed
sbdchd opened this issue Mar 14, 2024 · 4 comments
Closed
Labels
enhancement lsp-server graphql-language-service-server

Comments

@sbdchd
Copy link

sbdchd commented Mar 14, 2024

Basically if I have a schema first setup, I want to be able to click into a type in a graphql query string

import React from 'react';
import { useQuery } from '@apollo/client';
import { gql } from '@apollo/client';

const GET_USERS = gql`
  query GetUsers {
    users {
      id
      name
      email
    }
  }
`;

const UsersList = () => {
  const { loading, error, data } = useQuery(GET_USERS);
  return null;
}

When configured, clicking users should open the implementation rather than the graphql schema file.

relay has this via a vscode config option to call a program that returns the location as text

facebook/relay#4434

@sbdchd sbdchd added enhancement lsp-server graphql-language-service-server labels Mar 14, 2024
@acao
Copy link
Member

acao commented Mar 16, 2024

@sbdchd you need to disable the cacheSchemaForLookup setting in vscode and/or graphql config, wherever you have set it

@acao acao closed this as completed Mar 16, 2024
@patrick91
Copy link
Member

@acao how does this work? I want to add support for Go To Definition from a GraphQL file to the definition for Strawberry GraphQL 😊

@acao
Copy link
Member

acao commented May 22, 2024

the jump to definition works by looking through all the graphql strings in a peoject to find the matching type name and jumping to the file

if you want it to jump to a source file instead of a GraphQL string, I will introduce the configurable locateCommand option as per relay lsp

@patrick91
Copy link
Member

@acao ah yes, that would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement lsp-server graphql-language-service-server
Projects
None yet
Development

No branches or pull requests

3 participants