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.

Importing types, inputs, etc. using #import syntax

See original GitHub issue

Hi ✋

I want to use this package server side, to split my schema definition into multiple files.

Is it possible to use #import for complete types, inputs, etc. ? Or is it only supposed to work with fragments?

Bar.graphql

type Bar {
  name: String!
}

typeDefs.graphql

#import "./Bar.graphql"

type Query {
  bar: Bar
}

schema {
  query: Query
}

schema.js

import typeDefs from "./typeDefs.graphql";

I got this error

Error: Type "Bar" not found in document.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
detrohuttcommented, Jun 15, 2018

@yvele I’ve decided to go ahead and implement this feature. It’s going to take a day or two because:

  1. I have to write new tests to cover this functionality
  2. It’s going to involve some refactoring since the #import logic is tightly coupled with the non-schema file logic right now.

But I am working on it and will let you know as soon as I publish the new version!

2reactions
gregorycuellarcommented, Jun 29, 2018

I found I pushed PR #42 with fix + tests

Thanks @detrohutt

Read more comments on GitHub >

github_iconTop Results From Across the Web

import - JavaScript - MDN Web Docs - Mozilla
In order to use the import declaration in a source file, the file must be interpreted by the runtime as a module. In...
Read more >
Documentation - Modules - TypeScript
Prior to TypeScript 3.8, you can import a type using import . With TypeScript 3.8, you can import a type using the import...
Read more >
How to Dynamically Import JavaScript with Import Maps
An import map is a JavaScript object where the key is the name of the import ( @lodash/startCase ) and the value is...
Read more >
Import Statements in TypeScript: Which Syntax to Use
TypeScript has multiple syntaxes for imports. When should you use which? It depends. In this blog, Jessica Kerr shares her thoughts, ...
Read more >
type-only imports — A new TypeScript feature that benefits ...
You've decided you're going to use Babel and write your source in TypeScript. But what happens when you're sharing TS types across module ......
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