Upgrade tests based on schema printing

graphql-core 3 prints the descriptions, and skips `schema` if it's the default one (query: Query)
This commit is contained in:
Tomasz Kontusz 2019-09-15 18:25:58 +02:00
parent c2ae343a41
commit c7dea56e52
2 changed files with 78 additions and 18 deletions

View File

@ -783,38 +783,55 @@ def test_integer_field_filter_type():
assert str(schema) == dedent( assert str(schema) == dedent(
"""\ """\
schema { \"""An object with an ID\"""
query: Query
}
interface Node { interface Node {
\"""The ID of the object\"""
id: ID! id: ID!
} }
\"""
The Relay compliant `PageInfo` type, containing data necessary to paginate this connection.
\"""
type PageInfo { type PageInfo {
\"""When paginating forwards, are there more items?\"""
hasNextPage: Boolean! hasNextPage: Boolean!
\"""When paginating backwards, are there more items?\"""
hasPreviousPage: Boolean! hasPreviousPage: Boolean!
\"""When paginating backwards, the cursor to continue.\"""
startCursor: String startCursor: String
\"""When paginating forwards, the cursor to continue.\"""
endCursor: String endCursor: String
} }
type PetType implements Node { type PetType implements Node {
age: Int! age: Int!
\"""The ID of the object\"""
id: ID! id: ID!
} }
type PetTypeConnection { type PetTypeConnection {
\"""Pagination data for this connection.\"""
pageInfo: PageInfo! pageInfo: PageInfo!
\"""Contains the nodes in this connection.\"""
edges: [PetTypeEdge]! edges: [PetTypeEdge]!
} }
\"""A Relay edge containing a `PetType` and its cursor.\"""
type PetTypeEdge { type PetTypeEdge {
\"""The item at the end of the edge\"""
node: PetType node: PetType
\"""A cursor for use in pagination\"""
cursor: String! cursor: String!
} }
type Query { type Query {
pets(before: String, after: String, first: Int, last: Int, age: Int): PetTypeConnection pets(before: String = null, after: String = null, first: Int = null, last: Int = null, age: Int = null): PetTypeConnection
} }
""" """
) )

View File

@ -118,53 +118,95 @@ schema {
query: RootQuery query: RootQuery
} }
\"""Article description\"""
type Article implements Node { type Article implements Node {
\"""The ID of the object\"""
id: ID! id: ID!
headline: String! headline: String!
pubDate: Date! pubDate: Date!
pubDateTime: DateTime! pubDateTime: DateTime!
reporter: Reporter! reporter: Reporter!
editor: Reporter! editor: Reporter!
\"""Language\"""
lang: ArticleLang! lang: ArticleLang!
importance: ArticleImportance importance: ArticleImportance
} }
type ArticleConnection { type ArticleConnection {
\"""Pagination data for this connection.\"""
pageInfo: PageInfo! pageInfo: PageInfo!
\"""Contains the nodes in this connection.\"""
edges: [ArticleEdge]! edges: [ArticleEdge]!
test: String test: String
} }
\"""A Relay edge containing a `Article` and its cursor.\"""
type ArticleEdge { type ArticleEdge {
\"""The item at the end of the edge\"""
node: Article node: Article
\"""A cursor for use in pagination\"""
cursor: String! cursor: String!
} }
\"""An enumeration.\"""
enum ArticleImportance { enum ArticleImportance {
\"""Very important\"""
A_1 A_1
\"""Not as important\"""
A_2 A_2
} }
\"""An enumeration.\"""
enum ArticleLang { enum ArticleLang {
\"""Spanish\"""
ES ES
\"""English\"""
EN EN
} }
\"""
The `Date` scalar type represents a Date
value as specified by
[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
\"""
scalar Date scalar Date
\"""
The `DateTime` scalar type represents a DateTime
value as specified by
[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
\"""
scalar DateTime scalar DateTime
\"""An object with an ID\"""
interface Node { interface Node {
\"""The ID of the object\"""
id: ID! id: ID!
} }
\"""
The Relay compliant `PageInfo` type, containing data necessary to paginate this connection.
\"""
type PageInfo { type PageInfo {
\"""When paginating forwards, are there more items?\"""
hasNextPage: Boolean! hasNextPage: Boolean!
\"""When paginating backwards, are there more items?\"""
hasPreviousPage: Boolean! hasPreviousPage: Boolean!
\"""When paginating backwards, the cursor to continue.\"""
startCursor: String startCursor: String
\"""When paginating forwards, the cursor to continue.\"""
endCursor: String endCursor: String
} }
\"""Reporter description\"""
type Reporter { type Reporter {
id: ID! id: ID!
firstName: String! firstName: String!
@ -173,20 +215,29 @@ type Reporter {
pets: [Reporter!]! pets: [Reporter!]!
aChoice: ReporterAChoice aChoice: ReporterAChoice
reporterType: ReporterReporterType reporterType: ReporterReporterType
articles(before: String, after: String, first: Int, last: Int): ArticleConnection! articles(before: String = null, after: String = null, first: Int = null, last: Int = null): ArticleConnection!
} }
\"""An enumeration.\"""
enum ReporterAChoice { enum ReporterAChoice {
\"""this\"""
A_1 A_1
\"""that\"""
A_2 A_2
} }
\"""An enumeration.\"""
enum ReporterReporterType { enum ReporterReporterType {
\"""Regular\"""
A_1 A_1
\"""CNN Reporter\"""
A_2 A_2
} }
type RootQuery { type RootQuery {
\"""The ID of the object\"""
node(id: ID!): Node node(id: ID!): Node
} }
""".lstrip() """.lstrip()
@ -346,10 +397,6 @@ class TestDjangoObjectType:
assert str(schema) == dedent( assert str(schema) == dedent(
"""\ """\
schema {
query: Query
}
type Pet { type Pet {
id: ID! id: ID!
kind: String! kind: String!
@ -375,18 +422,18 @@ class TestDjangoObjectType:
assert str(schema) == dedent( assert str(schema) == dedent(
"""\ """\
schema {
query: Query
}
type Pet { type Pet {
id: ID! id: ID!
kind: PetModelKind! kind: PetModelKind!
cuteness: Int! cuteness: Int!
} }
\"""An enumeration.\"""
enum PetModelKind { enum PetModelKind {
\"""Cat\"""
CAT CAT
\"""Dog\"""
DOG DOG
} }
@ -409,10 +456,6 @@ class TestDjangoObjectType:
assert str(schema) == dedent( assert str(schema) == dedent(
"""\ """\
schema {
query: Query
}
type Pet { type Pet {
id: ID! id: ID!
kind: String! kind: String!