question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] [language server] implied fragments and support for imports

See original GitHub issue

In my GraphQL build system that I set up (built on top of graphql-code-generator and @graphql-tools/import) I require explicit fragment imports:

# import SomeFragment from "./some-path.graphql"

query MyQuery {
    someField { ...SomeFragment }
}

I do this in order to minimize the potential for fragment name conflicts and make it easier to share fragments across packages.

However, this language server seems to assume that all fragments are globally available which is not always the case. Is there a way to configure this? If not, would you accept a contribution to make this configurable?

I’m also curious to learn how others deal with sharing fragments across packages. Is using explicit imports good practice? Or is it better to make all fragments globally available and then be careful to make all fragment names unique across the codebase?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
patrickszmucercommented, Oct 11, 2021

@dotansimha I can believe that it’s hard to implement, and from what I’ve seen so far all the tooling support for imports is pretty variable (which is understandable given that this is not something that’s standarised).

However, I find it hard to imagine a world where we don’t support imports. Implied fragments work fine for small codebases, but for large monorepos where fragments are shared between many packages I feel like it’s going to be really hard to ensure that all fragments are unique.

1reaction
acaocommented, Oct 10, 2021

All excellent questions!

There is no agreed on/specified way to handle fragment imports, so we opted for the easier implied path for now

It would great to support graphql import style syntax as an opt-in feature

Read more comments on GitHub >

github_iconTop Results From Across the Web

Standard C++20 Modules support with MSVC in Visual Studio ...
/std:c++latest Implies C++ Modules. Private Module fragments are a new form of API encapsulation for primary Module interfaces.
Read more >
Fragment manager - Android Developers
FragmentManager allows you to support multiple back stacks with the saveBackStack() and restoreBackStack() methods. These methods allow you to ...
Read more >
IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
In [1]: import pandas as pd In [2]: from io import StringIO In [3]: data = "col1,col2,col3\na,b ... New in version 1.5.0: Support...
Read more >
API - esbuild
#ESM. The esm format stands for "ECMAScript module". It assumes the environment supports import and export syntax. Entry points ...
Read more >
Frequently Asked Questions About Studio
The Studio Editor supports Hebrew and Arabic characters, as well as bidirectional editing. Importing Files. Question: Can I import class definitions or routines ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found