-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94e4bb5
commit c57a9e3
Showing
8 changed files
with
153 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type Query { | ||
hello: String! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# import User from "./schema-b2.graphql" | ||
|
||
type Query { | ||
hello: String! | ||
user: User! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type User { | ||
name: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,61 @@ | ||
import test from 'ava' | ||
import { join } from 'path'; | ||
import { join } from 'path' | ||
import { printSchema } from 'graphql' | ||
const schema = require('../schema.json') | ||
import { getGraphQLConfig, GraphQLConfig } from '../../' | ||
|
||
const CONFIG_DIR = join(__dirname, 'config') | ||
|
||
let config:GraphQLConfig | ||
let config: GraphQLConfig | ||
|
||
test.beforeEach(() => { | ||
config = getGraphQLConfig(CONFIG_DIR) | ||
}) | ||
|
||
test('returns a correct name', (t) => { | ||
const testWithSchemaConfig = config.getProjectConfig('testWithSchema'); | ||
t.deepEqual(testWithSchemaConfig.projectName, 'testWithSchema'); | ||
}); | ||
test('returns a correct name', t => { | ||
const testWithSchemaConfig = config.getProjectConfig('testWithSchema') | ||
t.deepEqual(testWithSchemaConfig.projectName, 'testWithSchema') | ||
}) | ||
|
||
test('returns a correct root dir', (t) => t.deepEqual(config.configDir, CONFIG_DIR)); | ||
test('returns a correct root dir', t => { | ||
t.deepEqual(config.configDir, CONFIG_DIR) | ||
}) | ||
|
||
test('returns a correct schema path', (t) => { | ||
test('returns a correct schema path', t => { | ||
t.deepEqual( | ||
config.getProjectConfig('testWithSchema').schemaPath, | ||
join(CONFIG_DIR, '__schema__/StarWarsSchema.graphql') | ||
); | ||
t.deepEqual(config.getProjectConfig('testWithoutSchema').schemaPath, null); | ||
}); | ||
join(CONFIG_DIR, '__schema__/StarWarsSchema.graphql'), | ||
) | ||
t.deepEqual(config.getProjectConfig('testWithoutSchema').schemaPath, null) | ||
}) | ||
|
||
test('reads single schema', t => { | ||
const typeDefs = `\ | ||
type Query { | ||
hello: String! | ||
} | ||
` | ||
|
||
t.is( | ||
printSchema(config.getProjectConfig('testSchemaA').getSchema()), | ||
typeDefs, | ||
) | ||
}) | ||
|
||
test('reads imported schema', t => { | ||
const typeDefs = `\ | ||
type Query { | ||
hello: String! | ||
user: User! | ||
} | ||
type User { | ||
name: String | ||
} | ||
` | ||
|
||
t.is( | ||
printSchema(config.getProjectConfig('testSchemaB').getSchema()), | ||
typeDefs, | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.