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.5.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.5.1
Choose a head ref

Commits on Mar 27, 2018

  1. Copy the full SHA
    a2cdd82 View commit details

Commits on Apr 3, 2018

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    6fd935a View commit details
  2. Copy the full SHA
    048be45 View commit details
  3. Copy the full SHA
    733d2d6 View commit details

Commits on Apr 4, 2018

  1. Copy the full SHA
    79654cb View commit details
  2. Copy the full SHA
    b957c16 View commit details
  3. Copy the full SHA
    d65dce9 View commit details

Commits on Apr 5, 2018

  1. Copy the full SHA
    5749b3e View commit details
  2. Copy the full SHA
    fc078dc View commit details

Commits on Apr 6, 2018

  1. Copy the full SHA
    01d2c6f View commit details
  2. Copy the full SHA
    e5c4b07 View commit details

Commits on Apr 7, 2018

  1. Copy the full SHA
    0a1b1d4 View commit details

Commits on Apr 8, 2018

  1. Copy the full SHA
    c7fd3bc View commit details
  2. Update config.yml

    schickling authored Apr 8, 2018
    Copy the full SHA
    13f91eb View commit details
  3. Update renovate.json

    schickling authored Apr 8, 2018
    Copy the full SHA
    ed5fd6e View commit details

Commits on Apr 10, 2018

  1. Copy the full SHA
    51edf8d View commit details
  2. Copy the full SHA
    c7a43b5 View commit details

Commits on Apr 15, 2018

  1. Copy the full SHA
    cfd6bf8 View commit details
  2. Copy the full SHA
    7c16747 View commit details

Commits on Apr 18, 2018

  1. Copy the full SHA
    c32cfd2 View commit details
  2. Copy the full SHA
    42b15a1 View commit details

Commits on Apr 19, 2018

  1. Copy the full SHA
    92235c2 View commit details
  2. Copy the full SHA
    229439b View commit details

Commits on Apr 24, 2018

  1. Copy the full SHA
    03bb4c4 View commit details

Commits on Apr 25, 2018

  1. Copy the full SHA
    4d4ebd1 View commit details
  2. Fix file path import issues

    - Closes #147
    Mike Fix authored and Mike Fix committed Apr 25, 2018
    Copy the full SHA
    21dc3a3 View commit details
  3. Revert changes, add test to recreate issue

    Mike Fix authored and Mike Fix committed Apr 25, 2018
    Copy the full SHA
    14b3849 View commit details
  4. Update test assertion, fix bug

    Mike Fix authored and Mike Fix committed Apr 25, 2018
    Copy the full SHA
    ae31425 View commit details

Commits on Apr 26, 2018

  1. Copy the full SHA
    3ea11fa View commit details
  2. Copy the full SHA
    569ed49 View commit details
  3. Merge pull request #138 from graphcool/renovate/ts-node-6.x

    chore(deps): update dependency ts-node to v6
    schickling authored Apr 26, 2018
    Copy the full SHA
    80f87a9 View commit details
  4. Copy the full SHA
    61a39f5 View commit details
9 changes: 4 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -3,8 +3,7 @@ references:
run_tests: &run_tests
steps:
- checkout
- run: sudo npm install -g yarn
- run: yarn install
- run: yarn
- run:
name: test
command: |
@@ -31,14 +30,14 @@ jobs:
<<: *run_tests
build-node8:
docker:
- image: circleci/node
- image: circleci/node:8
<<: *run_tests
release:
docker:
- image: circleci/node
- image: circleci/node:latest
steps:
- checkout
- run: sudo npm install -g yarn semantic-release@12.0.0
- run: sudo npm install -g semantic-release
- run: yarn install
- run: semantic-release
- run: yarn docs
6 changes: 6 additions & 0 deletions fixtures/global/a.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# import * from "shared"

type A {
first: String
second: Shared
}
5 changes: 5 additions & 0 deletions fixtures/interfaces-implements-many/a.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# import B from "b.graphql"

type A implements B {
id: ID!
}
11 changes: 11 additions & 0 deletions fixtures/interfaces-implements-many/b.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
interface B {
id: ID!
}

type B1 implements B {
id: ID!
}

type B2 implements B {
id: ID!
}
7 changes: 7 additions & 0 deletions fixtures/interfaces-many/a.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# import B from "b.graphql"

type A implements B {
# test 1
first: String
second: Float
}
6 changes: 6 additions & 0 deletions fixtures/interfaces-many/b.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# import C from "c.graphql"

interface B {
second: Float
c: [C!]!
}
5 changes: 5 additions & 0 deletions fixtures/interfaces-many/c.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# import D1, D2 from "d.graphql"

type C implements D1 & D2 {
c: ID!
}
7 changes: 7 additions & 0 deletions fixtures/interfaces-many/d.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface D1 {
d1: ID!
}

interface D2 {
d2: ID!
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -46,18 +46,18 @@
},
"devDependencies": {
"@types/graphql": "0.12.6",
"@types/lodash": "4.14.106",
"@types/node": "9.6.0",
"@types/lodash": "4.14.108",
"@types/node": "9.6.7",
"ava": "0.25.0",
"ava-ts": "0.24.2",
"ava-ts": "0.24.4",
"graphql": "0.13.2",
"nyc": "11.6.0",
"nyc": "11.7.1",
"tap-xunit": "2.3.0",
"ts-node": "4.1.0",
"ts-node": "6.0.1",
"tslint": "5.9.1",
"tslint-config-standard": "7.0.0",
"typedoc": "0.11.1",
"typescript": "2.7.2"
"typescript": "2.8.3"
},
"dependencies": {
"lodash": "^4.17.4"
3 changes: 2 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": [
"config:base"
"config:base",
"docker:disable"
],
"automerge": true,
"major": {
67 changes: 67 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -363,6 +363,33 @@ type C {
t.is(importSchema('fixtures/interfaces/a.graphql'), expectedSDL)
})

test('importSchema: interfaces-many', t => {
const expectedSDL = `\
type A implements B {
first: String
second: Float
}
interface B {
second: Float
c: [C!]!
}
type C implements D1 & D2 {
c: ID!
}
interface D1 {
d1: ID!
}
interface D2 {
d2: ID!
}
`
t.is(importSchema('fixtures/interfaces-many/a.graphql'), expectedSDL)
})

test('importSchema: interfaces-implements', t => {
const expectedSDL = `\
type A implements B {
@@ -380,6 +407,27 @@ type B1 implements B {
t.is(importSchema('fixtures/interfaces-implements/a.graphql'), expectedSDL)
})

test('importSchema: interfaces-implements-many', t => {
const expectedSDL = `\
type A implements B {
id: ID!
}
interface B {
id: ID!
}
type B1 implements B {
id: ID!
}
type B2 implements B {
id: ID!
}
`
t.is(importSchema('fixtures/interfaces-implements-many/a.graphql'), expectedSDL)
})

test('importSchema: input types', t => {
const expectedSDL = `\
type A {
@@ -524,6 +572,25 @@ input PostFilter {
t.is(actualSDL, expectedSDL)
})

test('global schema modules', t => {
const shared = `
type Shared {
first: String
}
`
const expectedSDL = `\
type A {
first: String
second: Shared
}
type Shared {
first: String
}
`
t.is(importSchema('fixtures/global/a.graphql', { shared }), expectedSDL)
})

test('missing type on type', t => {
const err = t.throws(() => importSchema('fixtures/type-not-found/a.graphql'), Error)
t.is(err.message, `Field test: Couldn't find type Post in any of the schemas.`)
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -197,7 +197,9 @@ function collectDefinitions(
// Process each file (recursively)
rawModules.forEach(m => {
// If it was not yet processed (in case of circular dependencies)
const moduleFilePath = isFile(filePath) ? path.resolve(path.join(dirname, m.from)) : m.from
const moduleFilePath = isFile(filePath) && isFile(m.from)
? path.resolve(path.join(dirname, m.from))
: m.from
if (!processedFiles.has(moduleFilePath)) {
collectDefinitions(
m.imports,