File tree Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ export const viralSDL = `\
2
+ schema {
3
+ query: Query
4
+ }
5
+
6
+ type Query {
7
+ viruses: [Virus!]
8
+ }
9
+
10
+ type Virus {
11
+ name: String!
12
+ knownMutations: [Mutation!]!
13
+ }
14
+
15
+ type Mutation {
16
+ name: String!
17
+ geneSequence: String!
18
+ }\
19
+ ` ;
Original file line number Diff line number Diff line change
1
+ import {
2
+ GraphQLList ,
3
+ GraphQLNonNull ,
4
+ GraphQLObjectType ,
5
+ } from '../type/definition.js' ;
6
+ import { GraphQLString } from '../type/scalars.js' ;
7
+ import { GraphQLSchema } from '../type/schema.js' ;
8
+
9
+ const Mutation = new GraphQLObjectType ( {
10
+ name : 'Mutation' ,
11
+ fields : {
12
+ name : {
13
+ type : new GraphQLNonNull ( GraphQLString ) ,
14
+ } ,
15
+ geneSequence : {
16
+ type : new GraphQLNonNull ( GraphQLString ) ,
17
+ } ,
18
+ } ,
19
+ } ) ;
20
+
21
+ const Virus = new GraphQLObjectType ( {
22
+ name : 'Virus' ,
23
+ fields : {
24
+ name : {
25
+ type : new GraphQLNonNull ( GraphQLString ) ,
26
+ } ,
27
+ knownMutations : {
28
+ type : new GraphQLNonNull ( new GraphQLList ( new GraphQLNonNull ( Mutation ) ) ) ,
29
+ } ,
30
+ } ,
31
+ } ) ;
32
+
33
+ const Query = new GraphQLObjectType ( {
34
+ name : 'Query' ,
35
+ fields : {
36
+ viruses : {
37
+ type : new GraphQLList ( new GraphQLNonNull ( Virus ) ) ,
38
+ } ,
39
+ } ,
40
+ } ) ;
41
+
42
+ export const viralSchema = new GraphQLSchema ( {
43
+ query : Query ,
44
+ } ) ;
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { expect } from 'chai';
2
2
import { describe , it } from 'mocha' ;
3
3
4
4
import { dedent , dedentString } from '../../__testUtils__/dedent.js' ;
5
+ import { viralSchema } from '../../__testUtils__/viralSchema.js' ;
6
+ import { viralSDL } from '../../__testUtils__/viralSDL.js' ;
5
7
6
8
import { DirectiveLocation } from '../../language/directiveLocation.js' ;
7
9
@@ -867,4 +869,8 @@ describe('Type System Printer', () => {
867
869
}
868
870
` ) ;
869
871
} ) ;
872
+ it ( 'prints viral schema correctly' , ( ) => {
873
+ const printed = printSchema ( viralSchema ) ;
874
+ expect ( printed ) . to . equal ( viralSDL ) ;
875
+ } ) ;
870
876
} ) ;
You can’t perform that action at this time.
0 commit comments