src/Generators/SchemaGenerator.php
private function generateQueriesForDefinedTypes(array $definedTypes, array $definitionFileDirectories): string
    {
        $queries = [];
        $mutations = [];
        $inputTypes = [];

        /**
         * @var string $typeName
         * @var Type $type
         */
        foreach ($definedTypes as $typeName => $type) {
            $paginateAndAllQuery = PaginateAllQueryGenerator::generate($typeName, $type);

            if (! empty($paginateAndAllQuery)) {
                $queries[] = $paginateAndAllQuery;
            }
            $findQuery = FindQueryGenerator::generate($typeName, $type);

            if (! empty($findQuery)) {
                $queries[] = $findQuery;
            }

            $createMutation = createMutationWithInputTypeGenerator::generate($typeName, $type);
            if ($createMutation->isNotEmpty()) {
                $mutations[] = $createMutation->getMutation();
                $inputTypes[] = $createMutation->getInputType();
            }

            $updateMutation = updateMutationWithInputTypeGenerator::generate($typeName, $type);
            if ($updateMutation->isNotEmpty()) {
                $mutations[] = $updateMutation->getMutation();
                $inputTypes[] = $updateMutation->getInputType();
            }

            $deleteMutation = DeleteMutationGenerator::generate($typeName, $type);
            if (! empty($deleteMutation)) {
                $mutations[] = $deleteMutation;
            }
        }

        $queries = array_merge(
            $queries,
            $this->definitionsParser->parseCustomQueriesFrom($definitionFileDirectories['queries'])
        );

        $mutations = array_merge(
            $mutations,
            $this->definitionsParser->parseCustomMutationsFrom($definitionFileDirectories['mutations'])
        );

        $return = sprintf("type Query{\r\n%s\r\n}", implode("\r\n", $queries));
        $return .= "\r\n\r\n";
        $return .= sprintf("type Mutation{\r\n%s\r\n}", implode("\r\n", $mutations));
        $return .= "\r\n\r\n";
        $return .= implode("\r\n", $inputTypes);

        return $return;
    }
private function generateQueriesForDefinedTypes(array $definedTypes, array $definitionFileDirectories): string
    {
        $queries = [];
        $mutations = [];
        $inputTypes = [];

        /**
         * @var string $typeName
         * @var Type $type
         */
        foreach ($definedTypes as $typeName => $type) {
            $paginateAndAllQuery = PaginateAllQueryGenerator::generate($typeName, $type);

            if (! empty($paginateAndAllQuery)) {
                $queries[] = $paginateAndAllQuery;
            }
            $findQuery = FindQueryGenerator::generate($typeName, $type);

            if (! empty($findQuery)) {
                $queries[] = $findQuery;
            }

            $createMutation = createMutationWithInputTypeGenerator::generate($typeName, $type);
            if ($createMutation->isNotEmpty()) {
                $mutations[] = $createMutation->getMutation();
                $inputTypes[] = $createMutation->getInputType();
            }

            $updateMutation = updateMutationWithInputTypeGenerator::generate($typeName, $type);
            if ($updateMutation->isNotEmpty()) {
                $mutations[] = $updateMutation->getMutation();
                $inputTypes[] = $updateMutation->getInputType();
            }

            $deleteMutation = DeleteMutationGenerator::generate($typeName, $type);
            if (! empty($deleteMutation)) {
                $mutations[] = $deleteMutation;
            }
        }

        $queries = array_merge(
            $queries,
            $this->definitionsParser->parseCustomQueriesFrom($definitionFileDirectories['queries'])
        );

        $mutations = array_merge(
            $mutations,
            $this->definitionsParser->parseCustomMutationsFrom($definitionFileDirectories['mutations'])
        );

        $return = sprintf("type Query{\r\n%s\r\n}", implode("\r\n", $queries));
        $return .= "\r\n\r\n";
        $return .= sprintf("type Mutation{\r\n%s\r\n}", implode("\r\n", $mutations));
        $return .= "\r\n\r\n";
        $return .= implode("\r\n", $inputTypes);

        return $return;
    }
private function generateQueriesForDefinedTypes ( array $ definedTypes , array $ definitionFileDirectories ) : string { $ queries = [ ] ; $ mutations = [ ] ; $ inputTypes = [ ] ; /**
         * @var string $typeName
         * @var Type $type
         */ foreach ( $ definedTypes as $ typeName => $ type ) { $ paginateAndAllQuery = PaginateAllQueryGenerator :: generate ( $ typeName , $ type ) ; if ( ! empty ( $ paginateAndAllQuery ) ) { $ queries [ ] = $ paginateAndAllQuery ; } $ findQuery = FindQueryGenerator :: generate ( $ typeName , $ type ) ; if ( ! empty ( $ findQuery ) ) { $ queries [ ] = $ findQuery ; } $ createMutation = createMutationWithInputTypeGenerator :: generate ( $ typeName , $ type ) ; if ( $ createMutation -> isNotEmpty ( ) ) { $ mutations [ ] = $ createMutation -> getMutation ( ) ; $ inputTypes [ ] = $ createMutation -> getInputType ( ) ; } $ updateMutation = updateMutationWithInputTypeGenerator :: generate ( $ typeName , $ type ) ; if ( $ updateMutation -> isNotEmpty ( ) ) { $ mutations [ ] = $ updateMutation -> getMutation ( ) ; $ inputTypes [ ] = $ updateMutation -> getInputType ( ) ; } $ deleteMutation = DeleteMutationGenerator :: generate ( $ typeName , $ type ) ; if ( ! empty ( $ deleteMutation ) ) { $ mutations [ ] = $ deleteMutation ; } } $ queries = array_merge ( $ queries , $ this -> definitionsParser -> parseCustomQueriesFrom ( $ definitionFileDirectories [ 'queries' ] ) ) ; $ mutations = array_merge ( $ mutations , $ this -> definitionsParser -> parseCustomMutationsFrom ( $ definitionFileDirectories [ 'mutations' ] ) ) ; $ return = sprintf ( "type Query{\r\n%s\r\n}" , implode ( "\r\n" , $ queries ) ) ; $ return .= "\r\n\r\n" ; $ return .= sprintf ( "type Mutation{\r\n%s\r\n}" , implode ( "\r\n" , $ mutations ) ) ; $ return .= "\r\n\r\n" ; $ return .= implode ( "\r\n" , $ inputTypes ) ; return $ return ; }
Auto-generates a query for each definedType
These queries contain arguments for each field defined in the Type

@param array $definedTypes
@param array $definitionFileDirectories
@return string
Auto - generates a query for each definedType These queries contain arguments for each field defined in the Type