Skip to content

Commit 3e63dc1

Browse files
authored
Merge pull request #1 from graphql-java/master
sync
2 parents 96578f4 + cb7da2c commit 3e63dc1

28 files changed

Lines changed: 534 additions & 125 deletions

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ to checkout the appropriate tag when looking for the version documented here.
4040
- [Contributions](#contributions)
4141
- [Build it](#build-it)
4242
- [Development Build](#development-build)
43-
- [Javadocs](#javadocs)
4443
- [Details](#details)
4544
- [Acknowledgment](#acknowledgment)
4645
- [Related Projects](#related-projects)
@@ -65,8 +64,8 @@ take the time to read it.
6564

6665
If you have a question or want to discuss anything else related to this project:
6766

68-
- There is a mailing list (Google Group) for graphql-java: [graphql-java group](https://groups.google.com/forum/#!forum/graphql-java)
69-
- And a chat room (Gitter.im) for graphql-java: [graphql-java chat](https://gitter.im/graphql-java/graphql-java)
67+
- Feel free to open a new [Issue](https://github.com/graphql-java/graphql-java/issues)
68+
- We have a public chat room (Gitter.im) for graphql-java: [graphql-java chat](https://gitter.im/graphql-java/graphql-java)
7069

7170
### Hello World
7271

@@ -540,11 +539,6 @@ The latest development build is available on Bintray.
540539
Please look at [Latest Build](https://bintray.com/andimarek/graphql-java/graphql-java/_latestVersion) for the
541540
latest version value.
542541

543-
#### Javadocs
544-
545-
See the [project page](http://graphql-java.github.io/graphql-java/) for the javadocs associated with each release.
546-
547-
548542
#### How to use the latest build with Gradle
549543

550544
Add the repositories:

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,5 @@ tasks.withType(PublishToMavenRepository) {
146146

147147
task wrapper(type: Wrapper) {
148148
gradleVersion = '3.4'
149-
distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
149+
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
150150
}

src/main/java/graphql/language/Field.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
package graphql.language;
22

33

4+
import graphql.PublicApi;
5+
46
import java.util.ArrayList;
57
import java.util.List;
68

9+
/*
10+
* This is provided to a DataFetcher, therefore it is a public API.
11+
* This might change in the future.
12+
*/
13+
@PublicApi
714
public class Field extends AbstractNode implements Selection {
815

916
private String name;

src/main/java/graphql/language/FragmentDefinition.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package graphql.language;
22

33

4+
import graphql.PublicApi;
5+
46
import java.util.ArrayList;
57
import java.util.List;
68

9+
/**
10+
* Provided to the DataFetcher, therefore public API
11+
*/
12+
@PublicApi
713
public class FragmentDefinition extends AbstractNode implements Definition {
814

915
private String name;

src/main/java/graphql/language/OperationTypeDefinition.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package graphql.language;
22

33

4+
import graphql.Internal;
5+
46
import java.util.ArrayList;
57
import java.util.List;
68

9+
@Internal
710
public class OperationTypeDefinition extends AbstractNode {
811
private String name;
912
private Type type;

src/main/java/graphql/parser/GraphqlAntlrToLanguage.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package graphql.parser;
22

33

4+
import graphql.Internal;
45
import graphql.ShouldNotHappenException;
56
import graphql.language.AbstractNode;
67
import graphql.language.Argument;
@@ -57,6 +58,7 @@
5758
import java.util.Deque;
5859
import java.util.List;
5960

61+
@Internal
6062
public class GraphqlAntlrToLanguage extends GraphqlBaseVisitor<Void> {
6163

6264
private final CommonTokenStream tokens;

src/main/java/graphql/parser/Parser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package graphql.parser;
22

3+
import graphql.Internal;
34
import graphql.language.Document;
45
import graphql.parser.antlr.GraphqlLexer;
56
import graphql.parser.antlr.GraphqlParser;
@@ -12,6 +13,7 @@
1213

1314
import java.util.List;
1415

16+
@Internal
1517
public class Parser {
1618

1719
public Document parseDocument(String input) {

src/main/java/graphql/schema/DataFetchingEnvironment.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package graphql.schema;
22

3+
import graphql.PublicApi;
34
import graphql.execution.ExecutionId;
45
import graphql.language.Field;
56
import graphql.language.FragmentDefinition;
@@ -10,6 +11,7 @@
1011
/**
1112
* A DataFetchingEnvironment instance of passed to a {@link DataFetcher} as an execution context parameter
1213
*/
14+
@PublicApi
1315
public interface DataFetchingEnvironment {
1416
/**
1517
* @param <T> you decide what type it is

src/main/java/graphql/schema/GraphQLSchema.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public boolean isSupportingMutations() {
8181
return mutationType != null;
8282
}
8383

84+
public boolean isSupportingSubscriptions() {
85+
return subscriptionType != null;
86+
}
87+
8488
public static Builder newSchema() {
8589
return new Builder();
8690
}

src/main/java/graphql/schema/idl/SchemaGenerator.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import graphql.language.Type;
2323
import graphql.language.TypeDefinition;
2424
import graphql.language.TypeExtensionDefinition;
25-
import graphql.language.TypeName;
2625
import graphql.language.UnionTypeDefinition;
2726
import graphql.language.Value;
2827
import graphql.schema.DataFetcher;
@@ -42,6 +41,8 @@
4241
import graphql.schema.PropertyDataFetcher;
4342
import graphql.schema.TypeResolver;
4443
import graphql.schema.TypeResolverProxy;
44+
import graphql.schema.idl.errors.NotAnInputTypeError;
45+
import graphql.schema.idl.errors.NotAnOutputTypeError;
4546
import graphql.schema.idl.errors.SchemaProblem;
4647

4748
import java.util.Collections;
@@ -53,7 +54,7 @@
5354
import java.util.Stack;
5455

5556
/**
56-
* This can generate a working runtime schema from a compiled type registry and runtime wiring
57+
* This can generate a working runtime schema from a type registry and runtime wiring
5758
*/
5859
public class SchemaGenerator {
5960

@@ -133,7 +134,7 @@ public SchemaGenerator() {
133134
/**
134135
* This will take a {@link TypeDefinitionRegistry} and a {@link RuntimeWiring} and put them together to create a executable schema
135136
*
136-
* @param typeRegistry this can be obtained via {@link SchemaCompiler#compile(String)}
137+
* @param typeRegistry this can be obtained via {@link SchemaParser#parse(String)}
137138
* @param wiring this can be built using {@link RuntimeWiring#newRuntimeWiring()}
138139
* @return an executable schema
139140
* @throws SchemaProblem if there are problems in assembling a schema such as missing type resolvers or no operations defined
@@ -157,9 +158,11 @@ private GraphQLSchema makeExecutableSchemaImpl(BuildContext buildCtx) {
157158
@SuppressWarnings("OptionalGetWithoutIsPresent")
158159
OperationTypeDefinition queryOp = operationTypes.stream().filter(op -> "query".equals(op.getName())).findFirst().get();
159160
Optional<OperationTypeDefinition> mutationOp = operationTypes.stream().filter(op -> "mutation".equals(op.getName())).findFirst();
161+
Optional<OperationTypeDefinition> subscriptionOp = operationTypes.stream().filter(op -> "subscription".equals(op.getName())).findFirst();
160162

161163
GraphQLObjectType query = buildOperation(buildCtx, queryOp);
162164
GraphQLObjectType mutation;
165+
GraphQLObjectType subscription;
163166

164167
GraphQLSchema.Builder schemaBuilder = GraphQLSchema
165168
.newSchema()
@@ -169,6 +172,10 @@ private GraphQLSchema makeExecutableSchemaImpl(BuildContext buildCtx) {
169172
mutation = buildOperation(buildCtx, mutationOp.get());
170173
schemaBuilder.mutation(mutation);
171174
}
175+
if (subscriptionOp.isPresent()) {
176+
subscription = buildOperation(buildCtx, subscriptionOp.get());
177+
schemaBuilder.subscription(subscription);
178+
}
172179
return schemaBuilder.build();
173180
}
174181

@@ -213,8 +220,11 @@ private <T extends GraphQLOutputType> T buildOutputType(BuildContext buildCtx, T
213220
outputType = buildUnionType(buildCtx, (UnionTypeDefinition) typeDefinition);
214221
} else if (typeDefinition instanceof EnumTypeDefinition) {
215222
outputType = buildEnumType((EnumTypeDefinition) typeDefinition);
216-
} else {
223+
} else if (typeDefinition instanceof ScalarTypeDefinition){
217224
outputType = buildScalar(buildCtx, (ScalarTypeDefinition) typeDefinition);
225+
} else {
226+
// typeDefinition is not a valid output type
227+
throw new NotAnOutputTypeError(typeDefinition);
218228
}
219229

220230
buildCtx.put(outputType);
@@ -243,8 +253,11 @@ private GraphQLInputType buildInputType(BuildContext buildCtx, Type rawType) {
243253
inputType = buildInputObjectType(buildCtx, (InputObjectTypeDefinition) typeDefinition);
244254
} else if (typeDefinition instanceof EnumTypeDefinition) {
245255
inputType = buildEnumType((EnumTypeDefinition) typeDefinition);
246-
} else {
256+
} else if (typeDefinition instanceof ScalarTypeDefinition){
247257
inputType = buildScalar(buildCtx, (ScalarTypeDefinition) typeDefinition);
258+
} else {
259+
// typeDefinition is not a valid InputType
260+
throw new NotAnInputTypeError(typeDefinition);
248261
}
249262

250263
buildCtx.put(inputType);
@@ -253,6 +266,7 @@ private GraphQLInputType buildInputType(BuildContext buildCtx, Type rawType) {
253266
}
254267

255268
private GraphQLObjectType buildObjectType(BuildContext buildCtx, ObjectTypeDefinition typeDefinition) {
269+
256270
GraphQLObjectType.Builder builder = GraphQLObjectType.newObject();
257271
builder.name(typeDefinition.getName());
258272
builder.description(buildDescription(typeDefinition));
@@ -331,7 +345,8 @@ private GraphQLUnionType buildUnionType(BuildContext buildCtx, UnionTypeDefiniti
331345
builder.typeResolver(getTypeResolver(buildCtx, typeDefinition.getName()));
332346

333347
typeDefinition.getMemberTypes().forEach(mt -> {
334-
builder.possibleType(new GraphQLTypeReference(((TypeName) mt).getName()));
348+
GraphQLObjectType objectType = buildOutputType(buildCtx, mt);
349+
builder.possibleType(objectType);
335350
});
336351
return builder.build();
337352
}
@@ -460,4 +475,4 @@ private String buildDescription(Node node) {
460475
}
461476
return sb.toString();
462477
}
463-
}
478+
}

0 commit comments

Comments
 (0)