Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ardatan/graphql-import
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.7.0
Choose a base ref
...
head repository: ardatan/graphql-import
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.7.1
Choose a head ref
  • 7 commits
  • 4 files changed
  • 3 contributors

Commits on Sep 6, 2018

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    renovate-bot Mend Renovate
    Copy the full SHA
    6c43322 View commit details

Commits on Sep 12, 2018

  1. fix typings

    timsuchanek committed Sep 12, 2018
    Copy the full SHA
    6fcb1c6 View commit details
  2. Copy the full SHA
    35147ce View commit details
  3. Copy the full SHA
    992a0f0 View commit details
  4. Merge pull request #228 from prisma/renovate/graphql-14.x

    feat(deps): update dependency @types/graphql to v14
    timsuchanek authored Sep 12, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5cf3390 View commit details
  5. chore: Update README.md

    timsuchanek authored Sep 12, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9ab6ea9 View commit details
  6. fix: typings

    timsuchanek committed Sep 12, 2018
    Copy the full SHA
    01a4637 View commit details
Showing with 16 additions and 20 deletions.
  1. +0 −6 .circleci/config.yml
  2. +1 −1 README.md
  3. +3 −3 package.json
  4. +12 −10 src/index.ts
6 changes: 0 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -20,10 +20,6 @@ references:
prefix: coverage

jobs:
build-node4:
docker:
- image: circleci/node:4
<<: *run_tests
build-node6:
docker:
- image: circleci/node:6
@@ -48,11 +44,9 @@ workflows:
version: 2
build:
jobs:
- build-node4
- build-node6
- build-node8
- release:
requires:
- build-node4
- build-node6
- build-node8
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# graphql-import

[![CircleCI](https://circleci.com/gh/prismagraphql/graphql-import.svg?style=shield)](https://circleci.com/gh/prismagraphql/graphql-import) [![npm version](https://badge.fury.io/js/graphql-import.svg)](https://badge.fury.io/js/graphql-import)
[![CircleCI](https://circleci.com/gh/prisma/graphql-import.svg?style=shield)](https://circleci.com/gh/prisma/graphql-import) [![npm version](https://badge.fury.io/js/graphql-import.svg)](https://badge.fury.io/js/graphql-import)

Import &amp; export definitions in GraphQL SDL (also refered to as GraphQL modules)

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -35,16 +35,16 @@
"cp ./now.json ./docs && cd docs && now --public -f && now alias && now rm --yes --safe graphql-import & cd .."
},
"peerDependencies": {
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0"
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
},
"devDependencies": {
"@types/graphql": "0.12.6",
"@types/graphql": "14.0.0",
"@types/lodash": "4.14.116",
"@types/resolve-from": "0.0.18",
"@types/node": "9.6.31",
"ava": "0.25.0",
"ava-ts": "0.25.1",
"graphql": "0.13.2",
"graphql": "14.0.2",
"nyc": "11.8.0",
"tap-xunit": "2.3.0",
"ts-node": "7.0.1",
22 changes: 12 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ export function importSchema(
schemas?: { [key: string]: string },
): string {
const sdl = read(schema, schemas) || schema
const document = getDocumentFromSDL(sdl)
let document = getDocumentFromSDL(sdl)

// Recursively process the imports, starting by importing all types from the initial schema
let { allDefinitions, typeDefinitions } = collectDefinitions(
@@ -122,12 +122,14 @@ export function importSchema(
}
}

document.definitions = completeDefinitionPool(
flatten(allDefinitions),
firstSet,
flatten(typeDefinitions),
)

document = {
...document,
definitions: completeDefinitionPool(
flatten(allDefinitions),
firstSet,
flatten(typeDefinitions),
),
}
// Return the schema as string
return print(document)
}
@@ -269,7 +271,7 @@ function collectDefinitions(
*/
function filterImportedDefinitions(
imports: string[],
typeDefinitions: DefinitionNode[],
typeDefinitions: ReadonlyArray<DefinitionNode>,
allDefinitions: ValidDefinitionNode[][] = [],
): ValidDefinitionNode[] {
// This should do something smart with fields
@@ -306,7 +308,7 @@ function filterImportedDefinitions(
const fields = groupedFieldImports[rootType].map(x => x.split('.')[1])
;(filteredDefinitions.find(
def => def.name.value === rootType,
) as ObjectTypeDefinitionNode).fields = (filteredDefinitions.find(
) as any).fields = (filteredDefinitions.find(
def => def.name.value === rootType,
) as ObjectTypeDefinitionNode).fields.filter(
f => includes(fields, f.name.value) || includes(fields, '*'),
@@ -324,7 +326,7 @@ function filterImportedDefinitions(
* @returns Relevant type definitions
*/
function filterTypeDefinitions(
definitions: DefinitionNode[],
definitions: ReadonlyArray<DefinitionNode>,
): ValidDefinitionNode[] {
const validKinds = [
'DirectiveDefinition',