src/Generators/SchemaGenerator.php
public function generate(array $definitionFileDirectories): string
    {
        $authEnabled = config('lighthouse-utils.authorization');
        if ($authEnabled) {
            GraphQLSchema::truncate();
        }

        $this->validateFilesPaths($definitionFileDirectories);

        $schema = $this->getSchemaForFiles($definitionFileDirectories);

        $definedTypes = $this->getDefinedTypesFromSchema($schema, $definitionFileDirectories);

        $queries = $this->generateQueriesForDefinedTypes($definedTypes, $definitionFileDirectories);
        $typesImports = $this->concatSchemaDefinitionFilesFromPath(
            $this->definitionsParser->getGraphqlDefinitionFilePaths($definitionFileDirectories['types'])
        );

        if ($authEnabled) {
            event(new GraphQLSchemaGenerated(GraphQLSchema::all()));
        }

        //Merge queries and types into one file with required newlines
        return sprintf("%s\r\n\r\n%s\r\n", $typesImports, $queries);
    }
public function generate(array $definitionFileDirectories): string
    {
        $authEnabled = config('lighthouse-utils.authorization');
        if ($authEnabled) {
            GraphQLSchema::truncate();
        }

        $this->validateFilesPaths($definitionFileDirectories);

        $schema = $this->getSchemaForFiles($definitionFileDirectories);

        $definedTypes = $this->getDefinedTypesFromSchema($schema, $definitionFileDirectories);

        $queries = $this->generateQueriesForDefinedTypes($definedTypes, $definitionFileDirectories);
        $typesImports = $this->concatSchemaDefinitionFilesFromPath(
            $this->definitionsParser->getGraphqlDefinitionFilePaths($definitionFileDirectories['types'])
        );

        if ($authEnabled) {
            event(new GraphQLSchemaGenerated(GraphQLSchema::all()));
        }

        //Merge queries and types into one file with required newlines
        return sprintf("%s\r\n\r\n%s\r\n", $typesImports, $queries);
    }
public function generate ( array $ definitionFileDirectories ) : string { $ authEnabled = config ( 'lighthouse-utils.authorization' ) ; if ( $ authEnabled ) { GraphQLSchema :: truncate ( ) ; } $ this -> validateFilesPaths ( $ definitionFileDirectories ) ; $ schema = $ this -> getSchemaForFiles ( $ definitionFileDirectories ) ; $ definedTypes = $ this -> getDefinedTypesFromSchema ( $ schema , $ definitionFileDirectories ) ; $ queries = $ this -> generateQueriesForDefinedTypes ( $ definedTypes , $ definitionFileDirectories ) ; $ typesImports = $ this -> concatSchemaDefinitionFilesFromPath ( $ this -> definitionsParser -> getGraphqlDefinitionFilePaths ( $ definitionFileDirectories [ 'types' ] ) ) ; if ( $ authEnabled ) { event ( new GraphQLSchemaGenerated ( GraphQLSchema :: all ( ) ) ) ; } //Merge queries and types into one file with required newlines return sprintf ( "%s\r\n\r\n%s\r\n" , $ typesImports , $ queries ) ; }
Generates a schema from an array of definition file directories
For now, this only supports Types.
In the future it should also support Mutations and Queries.

@param array $definitionFileDirectories
@return string Generated Schema with Types and Queries
@throws InvalidConfigurationException
@throws \Nuwave\Lighthouse\Exceptions\DirectiveException
@throws \Nuwave\Lighthouse\Exceptions\ParseException
Generates a schema from an array of definition file directories For now this only supports Types . In the future it should also support Mutations and Queries .