-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserving graphQL descriptions as descriptions (not converting to co…
…mments) is now the default behaviour.
- Loading branch information
Björn Ekryd
committed
Mar 31, 2022
1 parent
2f4d7dc
commit 24c606c
Showing
15 changed files
with
407 additions
and
37 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
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
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
46 changes: 46 additions & 0 deletions
46
sorter/src/main/java/sortgraphql/sort/DescriptionOrComment.java
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,46 @@ | ||
package sortgraphql.sort; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
public class DescriptionOrComment { | ||
private final String comment; | ||
private final String description; | ||
|
||
private DescriptionOrComment(String comment, String description) { | ||
this.comment = comment; | ||
this.description = description; | ||
} | ||
|
||
public static DescriptionOrComment comment(String comment) { | ||
return new DescriptionOrComment(comment, null); | ||
} | ||
|
||
public static DescriptionOrComment description(String description) { | ||
return new DescriptionOrComment(null, description); | ||
} | ||
|
||
public boolean isNullOrEmpty() { | ||
return (comment == null || comment.isEmpty()) && (description == null || description.isEmpty()); | ||
} | ||
|
||
public boolean isDescription() { | ||
if (isNullOrEmpty()) { | ||
throw new IllegalStateException("Both comment and description is null"); | ||
} | ||
return comment == null; | ||
} | ||
|
||
public String getComment() { | ||
return comment; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public static List<String> lines(Supplier<String> fn) { | ||
return Arrays.asList(fn.get().split("\n")); | ||
} | ||
} |
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
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,95 @@ | ||
"a scalar" | ||
scalar _Any | ||
"used to represent a set of fields (minus the braces around them)." | ||
scalar _FieldSet | ||
|
||
"scary stuff" | ||
directive @supernatural("directive desc" scary: Boolean = true) on FIELD_DEFINITION | ||
|
||
"a directive" | ||
directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE | ||
|
||
""" | ||
Multi-line | ||
on type | ||
""" | ||
type Query { | ||
"A field" | ||
me :Me | ||
} | ||
|
||
"A type" | ||
type Me @key(fields: "id"){ | ||
""" | ||
Multi-line | ||
on field | ||
""" | ||
id: ID | ||
name: String | ||
} | ||
|
||
"The sound file of a howl" | ||
scalar Howl | ||
|
||
"Contains traits of both" | ||
union Werewolf = Person | Wolf | ||
|
||
interface Animal { | ||
doesHowl: Boolean | ||
} | ||
|
||
type Wolf { | ||
doesHowl: Boolean | ||
howl: Howl | ||
} | ||
|
||
type Person { | ||
traits: KindType | ||
} | ||
|
||
"Mutation" | ||
type Mutation { | ||
bite(victim: Victim): Werewolf @supernatural(scary: true) | ||
} | ||
|
||
"input" | ||
input Victim { | ||
"input field" | ||
traits: KindType | ||
} | ||
|
||
"another type" | ||
type Cat implements CuteAnimal & Animal { | ||
doesHowl: Boolean | ||
howl: Howl | ||
traits: KindType | ||
} | ||
|
||
"interface" | ||
interface CuteAnimal implements Animal { | ||
"interface field" | ||
doesHowl: Boolean | ||
} | ||
|
||
"enum" | ||
enum wereTypes { | ||
""" | ||
enum value | ||
multi-line | ||
""" | ||
WORM @deprecated | ||
WOLF | ||
BEAR | ||
} | ||
|
||
""" | ||
Random | ||
subscription | ||
""" | ||
type Subscription { | ||
monthlyWerewolf: Werewolf | ||
} | ||
|
||
enum KindType { | ||
KIND | ||
} |
Oops, something went wrong.