Skip to content

New comment handling (BREAKING CHANGE) #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 59 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ By adding comments in this format you allow the tester to create a query that wi

```graphql
type Query {
# Examples:
# playlist(id: "aihSOj7Qs0yzd6Kfc4x7Bg")
"""
Examples:
playlist(id: "aihSOj7Qs0yzd6Kfc4x7Bg")
"""
playlist(id: ID!): Playlist
}
```
Expand Down Expand Up @@ -58,14 +60,18 @@ Both queries and mutations are supported.

```graphql
type Query {
# Examples:
# playlist(id: "aihSOj7Qs0yzd6Kfc4x7Bg")
"""
Examples:
playlist(id: "aihSOj7Qs0yzd6Kfc4x7Bg")
"""
playlist(id: ID!): Playlist
}

type Mutation {
# Examples:
# createPlaylist(name: "Summer Mix")
"""
Examples:
createPlaylist(name: "Summer Mix")
"""
createPlaylist(name: String!): Playlist
}

Expand All @@ -81,8 +87,10 @@ Directives allow adding additional functionality to the tests by adding `@direct

```graphql
type Mutation {
# Examples:
# removePlaylist(id: "aihSOj7Qs0yzd6Kfc4x7Bg") @last()
"""
Examples:
removePlaylist(id: "aihSOj7Qs0yzd6Kfc4x7Bg") @last()
"""
removePlaylist(id: ID!): Playlist
}
```
Expand All @@ -93,8 +101,10 @@ Add an `@sla` directive to your query to tell it how long it should take to run.

```graphql
type Query {
# Examples:
# playlist(id: "aihSOj7Qs0yzd6Kfc4x7Bg") @sla(maxResponseTime: "600ms")
"""
Examples:
playlist(id: "aihSOj7Qs0yzd6Kfc4x7Bg") @sla(maxResponseTime: "600ms")
"""
playlist(id: ID!): Playlist
}
```
Expand All @@ -119,8 +129,10 @@ The `@wait` directive causes the tester to sleep for the amount of time before r

```graphql
type Query {
# Examples:
# playlist(id: "aihSOj7Qs0yzd6Kfc4x7Bg") @wait(waitTime: "1s")
"""
Examples:
playlist(id: "aihSOj7Qs0yzd6Kfc4x7Bg") @wait(waitTime: "1s")
"""
playlist(id: ID!): Playlist
}
```
Expand All @@ -141,9 +153,11 @@ Multiple queries can be defined for a single API.

```graphql
type Mutation {
# Examples:
# summerPlaylist: createPlaylist(name: "Summer Mix")
# fallPlaylist: createPlaylist(name: "Fall Mix")
"""
Examples:
summerPlaylist: createPlaylist(name: "Summer Mix")
fallPlaylist: createPlaylist(name: "Fall Mix")
"""
createPlaylist(name: String!): Playlist
}
```
Expand All @@ -156,16 +170,20 @@ The response data is stored in a variable using either the query name or the ali

```graphql
type Mutation {
# Examples:
# fallPlaylist: createPlaylist(name: "Fall Mix")
"""
Examples:
fallPlaylist: createPlaylist(name: "Fall Mix")
"""
createPlaylist(name: String!): Playlist
}

// fallPlaylist = Playlist (From the above Mutation)

type Query {
# Examples:
# playlist(id: "{{fallPlaylist.id}}")
"""
Examples:
playlist(id: "{{fallPlaylist.id}}")
"""
playlist(id: ID!): Playlist
}
```
Expand All @@ -176,14 +194,18 @@ When passing data between tests the tests become dependent on each other and the

```graphql
type Mutation {
# Examples:
# fallPlaylist: createPlaylist(name: "Fall Mix")
"""
Examples:
fallPlaylist: createPlaylist(name: "Fall Mix")
"""
createPlaylist(name: String!): Playlist
}

type Query {
# Examples:
# playlist(id: "{{fallPlaylist.id}}")
"""
Examples:
playlist(id: "{{fallPlaylist.id}}")
"""
playlist(id: ID!): Playlist
}
```
Expand All @@ -194,8 +216,10 @@ When tests contain mutations that remove or archive data it's often necessary to

```graphql
type Mutation {
# Examples:
# removePlaylist(id: "{{fallPlaylist.id}}") @last()
"""
Examples:
removePlaylist(id: "{{fallPlaylist.id}}") @last()
"""
removePlaylist(id: ID!): Playlist
}
```
Expand All @@ -206,8 +230,10 @@ The tester attempts to increase test coverage by retrieving every field availabl

```graphql
type Query {
# Examples:
# searchPlaylists(term: "Mix") @ensureMinimum(nItems: 2, inArrays:["searchPlaylists", "searchPlaylists.tracks"])
"""
Examples:
searchPlaylists(term: "Mix") @ensureMinimum(nItems: 2, inArrays:["searchPlaylists", "searchPlaylists.tracks"])
"""
searchPlaylists(term: String!): [Playlist!]!
}

Expand All @@ -231,16 +257,18 @@ When annotating, if you add `+NOFOLLOW` in examples will prevent this query from

```graphql
type Query {
# Examples:
# +NOFOLLOW
# ignoredQuery(name: "Ignore me")
"""
Examples:
+NOFOLLOW
ignoredQuery(name: "Ignore me")
"""
ignoredQuery(name: String): String
}
```

## Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

## License

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions src/schemaToQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ export default function schemaToQueries(rootName: string, schema): string[] {
/***
* type Query {
*
* # Examples:
* # track(id: "9108955fe473f1640ac38b9c")
* """
* Examples:
* track(id: "9108955fe473f1640ac38b9c")
* """
* track(id: ID!): Track
*
* # Examples:
* # playlist(id: "9108955fe473f1640ac38b9c")
* """
* Examples:
* playlist(id: "9108955fe473f1640ac38b9c")
* """
* playlist(id: ID!): Playlist
*
* }
Expand Down
44 changes: 28 additions & 16 deletions src/test/playlist.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,46 @@ type Query {
# This returns an array of Tags from the database
tags: [Tag]

# Examples:
# pl1: playlist(id: "{{summerPlaylist.id}}") @sla(maxResponseTime: "1s")
# pl2: playlist(id: "{{fallPlaylist.id}}") @ensureMinimum(nItems: 2, inArrays:["pl2.tracks"])
"""
Examples:
pl1: playlist(id: "{{summerPlaylist.id}}") @sla(maxResponseTime: "1s")
pl2: playlist(id: "{{fallPlaylist.id}}") @ensureMinimum(nItems: 2, inArrays:["pl2.tracks"])
"""
playlist(id: ID!): Playlist

# Examples:
# searchPlaylists(term: "Mix") @ensureMinimum(nItems: 2, inArrays:["searchPlaylists"])
"""
Examples:
searchPlaylists(term: "Mix") @ensureMinimum(nItems: 2, inArrays:["searchPlaylists"])
"""
searchPlaylists(term: String!): [Playlist!]!

# Examples:
# +NOFOLLOW
# ignoredQuery(name: "Ignore me")
"""
Examples:
+NOFOLLOW
ignoredQuery(name: "Ignore me")
"""
ignoredQuery(name: String): String
}

type Mutation {
# Examples:
# summerPlaylist: createPlaylist(name: "Summer Mix") @sla(maxResponseTime: ".5s")
# fallPlaylist: createPlaylist(name: "Fall Mix")
"""
Examples:
summerPlaylist: createPlaylist(name: "Summer Mix") @sla(maxResponseTime: ".5s")
fallPlaylist: createPlaylist(name: "Fall Mix")
"""
createPlaylist(name: String!): Playlist

# Examples:
# summerHitsPlaylist: updatePlaylist(id: "{{summerPlaylist.id}}", name: "Summer Hits")
"""
Examples:
summerHitsPlaylist: updatePlaylist(id: "{{summerPlaylist.id}}", name: "Summer Hits")
"""
updatePlaylist(id: ID!, name: String!): Playlist

# Examples:
# rp1: removePlaylist(id: "{{summerHitsPlaylist.id}}") @wait(waitTime:"1s") @last
# rp2: removePlaylist(id: "{{fallPlaylist.id}}") @last
"""
Examples:
rp1: removePlaylist(id: "{{summerHitsPlaylist.id}}") @wait(waitTime:"1s") @last
rp2: removePlaylist(id: "{{fallPlaylist.id}}") @last
"""
removePlaylist(id: ID!): Playlist
}

Expand Down