-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error logging for new interface type semantics (#350)
- Loading branch information
1 parent
51362e7
commit e6e8d19
Showing
2 changed files
with
69 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Copyright (c) 2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
import { | ||
GraphQLSchema, | ||
GraphQLInterfaceType, | ||
GraphQLObjectType, | ||
GraphQLString | ||
} from '../'; | ||
|
||
import { describe, it } from 'mocha'; | ||
import { expect } from 'chai'; | ||
|
||
const InterfaceType = new GraphQLInterfaceType({ | ||
name: 'Interface', | ||
fields: { fieldName: { type: GraphQLString } }, | ||
resolveType() { | ||
return ImplementingType; | ||
} | ||
}); | ||
|
||
const ImplementingType = new GraphQLObjectType({ | ||
name: 'Object', | ||
interfaces: [ InterfaceType ], | ||
fields: { fieldName: { type: GraphQLString, resolve: () => '' }} | ||
}); | ||
|
||
const Schema = new GraphQLSchema({ | ||
query: new GraphQLObjectType({ | ||
name: 'Query', | ||
fields: { | ||
getObject: { | ||
type: InterfaceType, | ||
resolve() { | ||
return {}; | ||
} | ||
} | ||
} | ||
}) | ||
}); | ||
|
||
describe('Type System: Schema', () => { | ||
describe('Getting possible types', () => { | ||
it('throws human-reable error if schema.types is not defined', () => { | ||
const checkPossible = () => { | ||
return Schema.isPossibleType(InterfaceType, ImplementingType); | ||
}; | ||
expect(checkPossible).to.throw( | ||
'Could not find possible implementing types for Interface in schema. ' + | ||
'Check that schema.types is defined and is an array ofall possible ' + | ||
'types in the schema.' | ||
); | ||
}); | ||
}); | ||
}); |
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