diff --git a/.circleci/config.yml b/.circleci/config.yml index 42b2b66..01513c2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,11 +1,9 @@ version: 2 -jobs: - build: - docker: - - image: circleci/node +references: + run_tests: &run_tests steps: - checkout - - run: sudo npm install -g yarn semantic-release@12.0.0 + - run: sudo npm install -g yarn - run: yarn install - run: name: test @@ -21,7 +19,41 @@ jobs: - store_artifacts: path: coverage prefix: coverage + +jobs: + build-node4: + docker: + - image: circleci/node:4 + <<: *run_tests + build-node6: + docker: + - image: circleci/node:6 + <<: *run_tests + build-node8: + docker: + - image: circleci/node + <<: *run_tests + release: + docker: + - image: circleci/node + steps: + - checkout + - run: sudo npm install -g yarn semantic-release@12.0.0 + - run: yarn install - run: semantic-release - run: yarn docs # needs proper NOW setup first # - run: yarn docs:publish + +workflows: + version: 2 + build: + jobs: + - build-node4 + - build-node6 + - build-node8 + - release: + requires: + - build-node4 + - build-node6 + - build-node8 diff --git a/package.json b/package.json index 3d59fcf..d3fefcb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,9 @@ { "name": "graphql-import", "version": "0.0.0-semantic-release", + "engines": { + "node": ">=4.0.0" + }, "license": "MIT", "repository": "git@github.com:graphcool/graphql-import.git", "files": [ diff --git a/src/definition.ts b/src/definition.ts index 2863ace..e9f2b2a 100644 --- a/src/definition.ts +++ b/src/definition.ts @@ -1,4 +1,4 @@ -import { keyBy, uniqBy } from 'lodash' +import { keyBy, uniqBy, includes } from 'lodash' import { DocumentNode, TypeDefinitionNode, @@ -147,7 +147,7 @@ function collectNewTypeDefinitions( // collect missing argument input types if ( !definitionPool.some(d => d.name.value === nodeTypeName) && - !builtinTypes.includes(nodeTypeName) + !includes(builtinTypes, nodeTypeName) ) { const argTypeMatch = schemaMap[nodeTypeName] if (!argTypeMatch) { @@ -165,7 +165,7 @@ function collectNewTypeDefinitions( const directiveName = directive.name.value if ( !definitionPool.some(d => d.name.value === directiveName) && - !builtinDirectives.includes(directiveName) + !includes(builtinDirectives, directiveName) ) { const directive = schemaMap[directiveName] as DirectiveDefinitionNode if (!directive) { diff --git a/src/index.ts b/src/index.ts index 8a63a6c..559d009 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import * as fs from 'fs' import { DefinitionNode, parse, print, TypeDefinitionNode, GraphQLObjectType, ObjectTypeDefinitionNode, DocumentNode, Kind } from 'graphql' -import { flatten, groupBy } from 'lodash' +import { flatten, groupBy, includes } from 'lodash' import * as path from 'path' import { @@ -88,13 +88,13 @@ export function importSchema(schema: string, schemas?: { [key: string]: string } // And should always be in the first set, to make sure they // are not filtered out. const typesToFilter = ['Query', 'Mutation', 'Subscription'] - const firstTypes = flatten(typeDefinitions).filter(d => typesToFilter.includes(d.name.value)) - const otherFirstTypes = typeDefinitions[0].filter(d => !typesToFilter.includes(d.name.value)) + const firstTypes = flatten(typeDefinitions).filter(d => includes(typesToFilter, d.name.value)) + const otherFirstTypes = typeDefinitions[0].filter(d => !includes(typesToFilter, d.name.value)) const firstSet = otherFirstTypes.concat(firstTypes) const processedTypeNames = [] const mergedFirstTypes = [] for (const type of firstSet) { - if (!processedTypeNames.includes(type.name.value)) { + if (!includes(processedTypeNames, type.name.value)) { processedTypeNames.push(type.name.value) mergedFirstTypes.push(type) } else { @@ -232,10 +232,10 @@ function filterImportedDefinitions( const filteredDefinitions = filterTypeDefinitions(typeDefinitions) - if (imports.includes('*')) { + if (includes(imports, '*')) { return filteredDefinitions } else { - const result = filteredDefinitions.filter(d => imports.map(i => i.split('.')[0]).includes(d.name.value)) + const result = filteredDefinitions.filter(d => includes(imports.map(i => i.split('.')[0]), d.name.value)) const fieldImports = imports .filter(i => i.split('.').length > 1) const groupedFieldImports = groupBy(fieldImports, x => x.split('.')[0]) @@ -244,7 +244,7 @@ function filterImportedDefinitions( const fields = groupedFieldImports[rootType].map(x => x.split('.')[1]); (filteredDefinitions.find(def => def.name.value === rootType) as ObjectTypeDefinitionNode).fields = (filteredDefinitions.find(def => def.name.value === rootType) as ObjectTypeDefinitionNode).fields - .filter(f => fields.includes(f.name.value) || fields.includes('*')) + .filter(f => includes(fields, f.name.value) || includes(fields, '*')) } return result @@ -270,6 +270,6 @@ function filterTypeDefinitions( 'InputObjectTypeDefinition' ] return definitions - .filter(d => validKinds.includes(d.kind)) + .filter(d => includes(validKinds, d.kind)) .map(d => d as ValidDefinitionNode) }