Closed zvictor closed 4 years ago
Could you remove #import
from the beginning of the file and try again?
Removing # import
gives me:
['base.gql', 'User.gql', 'Query.gql']
--> Renders only base.gql['base.gql', 'Query.gql']
--> Renders only base.gql['base.gql', 'User.gql']
--> Renders only base.gql'*.gql'
--> Throws an error['User.gql', 'base.gql']
--> Throws an error['Query.gql', 'base.gql']
--> Throws an error['Query.gql', 'User.gql', 'base.gql']
--> Throws an errorI started writing a reproducible to what I thought was a different issue, but it seems after all to actually be the same one. So, here we have another but simpler reproducible of this issue: https://github.com/zvictor/graphql-import-issue-565
Providing multiple sources has some bugs right now. Until we fix it, I recommend you to use single endpoint which is GraphQL Import's main strategy or use https://github.com/ardatan/graphql-toolkit#-file-loading-for-both-schema-and-resolvers for now because it seems you don't need import
syntax at all.
Unfortunately things are not that simple on my side. I am using your code inside a framework I am building, so it needs to be quite flexible 😕
As I am building something to work with faunadb's graphql api, I need to always append a file with generic types that already exist inside fauna but are not defined on the user's code.
You can see my implementation at
FYI just manually doing this works for me
const typeDefsResult = loadTypedefsSync('**/*.graphql', {
loaders: [new GraphQLFileLoader()],
})
const typeDefs = mergeTypeDefs(
typeDefsResult.flatMap(({ document }) => (document ? [document] : [])),
)
new ApolloServer({ typeDefs, ... })
it might be something to do with the mergeTypeDefs
options?
migrating from @graphql-toolkit to @graphql-tools has solved the issue to me, plus a customisation on the graphql-loader.
I am facing errors while using graphql-import that vary depending on how I am calling the
importSchema
function.First, I created a directory with 3 files, all containing valid graphql schemas:
Then I tried calling
importSchema
in multiple ways, but all of them showed problems. For each of the followingpointerOrPointers
, these are the results I got:['base.gql', 'User.gql', 'Query.gql']
--> Doesn't include Query.gql.['base.gql', 'Query.gql']
--> Doesn't include Query.gql.['base.gql', 'User.gql']
--> Shouldn't include Query.gql, but does.'*.gql'
--> Throws an error['User.gql', 'base.gql']
--> Throws an error['Query.gql', 'base.gql']
--> Throws an error['Query.gql', 'User.gql', 'base.gql']
--> Throws an errorI made a reproducible code showing the problem. Edit: a simpler reproducible has been created for this issue.