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

Error: Unknown type whith a reference to a type in another file #1782

Closed
francoisromain opened this issue Jul 15, 2020 · 3 comments
Closed

Comments

@francoisromain
Copy link

francoisromain commented Jul 15, 2020

I have 2 files: index.graphql and territoires.graphql.

index.graphql :

# import * from 'territoires.graphql'

type Query {
  pays: [Pays]
}

territoires.graphql

type Departement {
  id: ID!
}

type Region {
  id: ID!
  departements: [Departement]
}

type Pays {
  id: ID!
  regions: [Region]
}

The error is

/node_modules/graphql/validation/validate.js:108
throw new Error(errors.map(function (error) {
          ^
Error: Unknown type "Departement".

If I don't use a separate file and put everything in index.graphql like so, there is no error:

type Query {
  pays: [Pays]
}

type Departement {
  id: ID!
}

type Region {
  id: ID!
  departements: [Departement]
}

type Pays {
  id: ID!
  regions: [Region]
}

repro: https://github.com/francoisromain/graphql-tools-config-debug

This issue was originally opened here: ardatan/graphql-import#601. I think to belongs to graphql-tools.

Thank you

@stanley97dion
Copy link

stanley97dion commented Oct 25, 2020

Hi there,
Is there any follow-up or work in progress on this issue? I have got a similar case.
I have just migrated from writing SDL entirely in strings to dedicated .gql files to increase maintainability and code readability by having code Prettier and Highlighter in my editor.
However now I run into the same problem as @francoisromain
Sometimes I cant even successfully import a type that explicitly existed in one file. The error message is no different:

Error: Unknown type "PointReward". Did you mean "CouponReward"?

I have tried moving PointReward to the same file with the Type that uses it. Just like the above case with type "Departement" that is used directly on the same file. The error persists with the same message.
Hope to get a resolution soon since the official documentation doesn't tell much about it.

@steponas
Copy link
Contributor

This is a duplicate of #1591

@ardatan
Copy link
Owner

ardatan commented Apr 30, 2021

See #1591 (comment)

@ardatan ardatan closed this as completed Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants