From 30c7f9595c430d381c68c6f4c1fc650d3b89da3b Mon Sep 17 00:00:00 2001 From: Jon Wong Date: Mon, 15 Jan 2018 13:57:14 -0800 Subject: [PATCH 1/6] Testing CircleCI workflows --- .circleci/config.yml | 29 +++++++++++++++++++++++------ package.json | 3 +++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 42b2b66..ca0021e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,6 @@ 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 @@ -21,7 +19,26 @@ jobs: - store_artifacts: path: coverage prefix: coverage - - run: semantic-release - - run: yarn docs + # Removing this for now while I'm testing workflows. + # - run: semantic-release + # Add this in after fan-out. + # - run: yarn docs # needs proper NOW setup first # - run: yarn docs:publish + +jobs: + build-node4: + docker: + - image: circleci/node:4 + <<: *run_tests + build-node6: + docker: + - image: circleci/node:6 + <<: *run_tests + +workflows: + version: 2 + build: + jobs: + - build-node4 + - build-node6 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": [ From da72e96b9bbd52bb20c49ce14201d1703af006b7 Mon Sep 17 00:00:00 2001 From: Jon Wong Date: Mon, 15 Jan 2018 14:08:24 -0800 Subject: [PATCH 2/6] Adding Node 8, release script --- .circleci/config.yml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ca0021e..6c587b0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ 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 @@ -19,12 +19,6 @@ references: - store_artifacts: path: coverage prefix: coverage - # Removing this for now while I'm testing workflows. - # - run: semantic-release - # Add this in after fan-out. - # - run: yarn docs - # needs proper NOW setup first - # - run: yarn docs:publish jobs: build-node4: @@ -35,6 +29,19 @@ jobs: docker: - image: circleci/node:6 <<: *run_tests + build-node8: + docker: + - image: circleci/node + <<: *run_tests + release: + docker: + - image: circleci/node + steps: + - run: sudo npm install -g semantic-release@12.0.0 + - run: semantic-release + - run: yarn docs + # needs proper NOW setup first + # - run: yarn docs:publish workflows: version: 2 @@ -42,3 +49,9 @@ workflows: jobs: - build-node4 - build-node6 + - build-node8 + - release: + requires: + - build-node4 + - build-node6 + - build-node8 From ce332068b2b75e980c0297b83ccb1df14849a160 Mon Sep 17 00:00:00 2001 From: Jon Wong Date: Mon, 15 Jan 2018 14:12:02 -0800 Subject: [PATCH 3/6] Testing syntax --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6c587b0..d64098f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -50,8 +50,8 @@ workflows: - build-node4 - build-node6 - build-node8 - - release: - requires: - - build-node4 - - build-node6 - - build-node8 + # - release: + # requires: + # - build-node4 + # - build-node6 + # - build-node8 From 4b5ab5c90ca9688f7646143ae11c59a26dba228d Mon Sep 17 00:00:00 2001 From: Jon Wong Date: Mon, 15 Jan 2018 14:16:40 -0800 Subject: [PATCH 4/6] Trying release --- .circleci/config.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d64098f..da66604 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,7 +37,9 @@ jobs: docker: - image: circleci/node steps: - - run: sudo npm install -g semantic-release@12.0.0 + - 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 @@ -50,8 +52,8 @@ workflows: - build-node4 - build-node6 - build-node8 - # - release: - # requires: - # - build-node4 - # - build-node6 - # - build-node8 + - release: + requires: + - build-node4 + - build-node6 + - build-node8 From f3402ca85d31e7a82499196a05ed355be91594f8 Mon Sep 17 00:00:00 2001 From: Jon Wong Date: Mon, 15 Jan 2018 14:19:25 -0800 Subject: [PATCH 5/6] Fixing syntax --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index da66604..01513c2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,7 +53,7 @@ workflows: - build-node6 - build-node8 - release: - requires: - - build-node4 - - build-node6 - - build-node8 + requires: + - build-node4 + - build-node6 + - build-node8 From 7d757bffbcfd4344a6f20d1ac3b18b4648a47854 Mon Sep 17 00:00:00 2001 From: Jon Wong Date: Mon, 15 Jan 2018 14:36:45 -0800 Subject: [PATCH 6/6] Using `_.includes` for Node 4 support --- src/definition.ts | 6 +++--- src/index.ts | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) 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) }