MCPcopy Index your code
hub / github.com/graphql-java/graphql-java / ReadmeExamples

Class ReadmeExamples

src/test/groovy/readme/ReadmeExamples.java:71–520  ·  view source on GitHub ↗

This class holds readme examples so they stay correct and can be compiled. If this does not parse, chances are the readme examples are now wrong. You should place these examples into the README.next.md and NOT the main README.md. This allows 'master' to progress yet shows consumers the released i

Source from the content-addressed store, hash-verified

69 * 'master' to progress yet shows consumers the released information about the project.
70 */
71@SuppressWarnings({"unused", "Convert2Lambda", "UnnecessaryLocalVariable", "ConstantConditions", "SameParameterValue", "ClassCanBeStatic"})
72public class ReadmeExamples {
73
74
75 public Map<String, Object> getInputFromJSON() {
76 return new HashMap<>();
77 }
78
79 class Foo {
80 }
81
82 void creatingASchema() {
83 GraphQLSchema schema = GraphQLSchema.newSchema()
84 .query(queryType) // must be provided
85 .mutation(mutationType) // is optional
86 .build();
87
88 GraphQLUnionType.Builder description = newUnionType().description("");
89 description.definition(null).build();
90 }
91
92 void listsAndNonNullLists() {
93 GraphQLList.list(GraphQLString); // a list of Strings
94
95 GraphQLNonNull.nonNull(GraphQLString); // a non null String
96
97 // with static imports it's even shorter
98 newArgument()
99 .name("example")
100 .type(nonNull(list(GraphQLString)));
101 }
102
103 void newType() {
104 GraphQLObjectType simpsonCharacter = newObject()
105 .name("SimpsonCharacter")
106 .description("A Simpson character")
107 .field(newFieldDefinition()
108 .name("name")
109 .description("The name of the character.")
110 .type(GraphQLString))
111 .field(newFieldDefinition()
112 .name("mainCharacter")
113 .description("One of the main Simpson characters?")
114 .type(GraphQLBoolean))
115 .build();
116 }
117
118 void interfaceType() {
119 GraphQLInterfaceType comicCharacter = newInterface()
120 .name("ComicCharacter")
121 .description("A abstract comic character.")
122 .field(newFieldDefinition()
123 .name("name")
124 .description("The name of the character.")
125 .type(GraphQLString))
126 .build();
127 }
128

Callers

nothing calls this directly

Calls 5

newScalarMethod · 0.95
coercingMethod · 0.80
buildMethod · 0.65
descriptionMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…