-
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.
Fix ambiguity around when schema definition may be omitted (#3839)
This PR implements the tests and fixes necessary for [Spec RFC #987](graphql/graphql-spec#987). This PR is made of three main commits: 1. Test printing a schema that has `Query`, `Mutation` and `Virus` types, but only supports `query` operations (via the `Query` type) and does _not_ support `mutation` operations. 2. Test parsing this same schema text, and assert that the schema does not have a mutation type. 3. Fix the printing of the schema. Co-authored-by: Lee Byron <[email protected]>
- Loading branch information
Showing
5 changed files
with
110 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export const viralSDL = `\ | ||
schema { | ||
query: Query | ||
} | ||
type Query { | ||
viruses: [Virus!] | ||
} | ||
type Virus { | ||
name: String! | ||
knownMutations: [Mutation!]! | ||
} | ||
type Mutation { | ||
name: String! | ||
geneSequence: 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,44 @@ | ||
import { | ||
GraphQLList, | ||
GraphQLNonNull, | ||
GraphQLObjectType, | ||
} from '../type/definition.js'; | ||
import { GraphQLString } from '../type/scalars.js'; | ||
import { GraphQLSchema } from '../type/schema.js'; | ||
|
||
const Mutation = new GraphQLObjectType({ | ||
name: 'Mutation', | ||
fields: { | ||
name: { | ||
type: new GraphQLNonNull(GraphQLString), | ||
}, | ||
geneSequence: { | ||
type: new GraphQLNonNull(GraphQLString), | ||
}, | ||
}, | ||
}); | ||
|
||
const Virus = new GraphQLObjectType({ | ||
name: 'Virus', | ||
fields: { | ||
name: { | ||
type: new GraphQLNonNull(GraphQLString), | ||
}, | ||
knownMutations: { | ||
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(Mutation))), | ||
}, | ||
}, | ||
}); | ||
|
||
const Query = new GraphQLObjectType({ | ||
name: 'Query', | ||
fields: { | ||
viruses: { | ||
type: new GraphQLList(new GraphQLNonNull(Virus)), | ||
}, | ||
}, | ||
}); | ||
|
||
export const viralSchema = new GraphQLSchema({ | ||
query: Query, | ||
}); |
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