ardatan/graphql-import

Issue: Import Input

Closed this issue ยท 9 comments

would like to get some help about importing input type, cause # import CreateInput from 'prisma.graphql'; doesn't work.

Is there a way to accomplish that? ๐Ÿ™

@ccruz2886 Thanks for raising this, can you please provide a small reproduction repo? Thanks.

I'm also having this issue. Don't even need a repo to reproduce:

const { importSchema } = require('graphql-import');

const root = `
#import ExampleInput from "example"
`;

const example = `
input ExampleInput { 
  whatever: String! 
}
`;

const schema = importSchema(root, { example });

console.log(schema);

Expected Output

input ExampleInput { 
  whatever: String! 
}

Actual Output


+1 would love this to simplify my schema.graphql

I'm seeing the same issue with input types. Has this been confirmed as a bug? How are others working around not being able to import input types (e.g. generated Prisma schema)?

@corydeppen Input types seem to be automatically imported as needed, when specified by a query or mutation (such as when you import from a generated Prisma schema).

You just can't import them explicitly, or independently.
I honestly ended up combining graphql-import with my own file import system to work around this behavior.

k0d3d commented

@t3rminus how did u do this.. can i cherry pick Input Types and other types from the generated prisma schema

@k0d3d Sadly no. The problem I was trying to solve was having a single index file import all my separate schema files, but the input types weren't being included.

I only worked around it by loading and pre-combining the schema files myself, with some regex trickery to identify what was being imported from where. It's hacky, kind-of slow, and I don't recommend it.

Hi @ccruz2886 !
In 1.0.0 beta release, we introduced a lot of changes. We changed the way the files get loaded and merged etc.
Could you install graphql-import@beta to try new changes? Don't forget to modify your code regarding to the migration notes in README.
https://github.com/ardatan/graphql-import#updating-from-07x

Available in 1.0.0!