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

GraphQLFactory.mergeTypesByPaths not working with multiple patterns #31

Closed
ph55 opened this issue Jun 12, 2018 · 3 comments
Closed

GraphQLFactory.mergeTypesByPaths not working with multiple patterns #31

ph55 opened this issue Jun 12, 2018 · 3 comments

Comments

@ph55
Copy link

ph55 commented Jun 12, 2018

Following code

    const typeDefs = this.graphQLFactory.mergeTypesByPaths(
      `src/@core/**/*.graphqls`,
      `src/${process.env.APP_NAME}/**/*.graphqls`
    );

will only generate type definitions for first pattern: src/@core/**/*.graphqls, all next patterns not merged.

Manual merging fixes this issue:

    import { fileLoader, mergeTypes } from 'merge-graphql-schemas';

    const coreTypes = fileLoader(`src/@core/**/*.graphqls`);
    const appTypes = fileLoader(`src/${process.env.APP_NAME}/**/*.graphqls`);

    const types = coreTypes.concat(appTypes);

    const typeDefs = mergeTypes(types);
@matcic
Copy link

matcic commented Sep 1, 2018

@ph55 I found the same issue. Having a look at the source code https://github.com/nestjs/graphql/blob/master/lib/graphql.factory.ts#L43 seems to be the cause of the problem: a pattern potentially matches many files, which are then read and returned as an array of strings. A simple solution is just to deep flatten the argument to mergeTypes instead of simply spreading it. I hope this is an easy fix for you, @kamilmysliwiec 😄

@kamilmysliwiec
Copy link
Member

Fixed in 5.1.0

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants