Java Code Examples for graphql.schema.GraphQLSchema#getType()
The following examples show how to use
graphql.schema.GraphQLSchema#getType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FederationTest.java From federation-jvm with MIT License | 6 votes |
@Test void testInterfacesAreCovered() { final RuntimeWiring wiring = RuntimeWiring.newRuntimeWiring() .type(TypeRuntimeWiring.newTypeWiring("Product") .typeResolver(env -> null) .build()) .build(); final GraphQLSchema transformed = Federation.transform(interfacesSDL, wiring) .resolveEntityType(env -> null) .fetchEntities(environment -> null) .build(); final GraphQLUnionType entityType = (GraphQLUnionType) transformed.getType(_Entity.typeName); final Iterable<String> unionTypes = entityType .getTypes() .stream() .map(GraphQLNamedType::getName) .sorted() .collect(Collectors.toList()); assertIterableEquals(Arrays.asList("Book", "Movie", "Page"), unionTypes); }
Example 2
Source File: OperationInfoTest.java From graphql-spqr with Apache License 2.0 | 6 votes |
private void testEnumValues(boolean respectJavaDeprecation) { GraphQLSchema schema = new GraphQLSchemaGenerator() .withOperationsFromSingleton(new BunnyService()) .withJavaDeprecationRespected(respectJavaDeprecation) .generate(); GraphQLEnumType bunnyType = (GraphQLEnumType) schema.getType("BunnyType"); assertEquals("Types of bunnies", bunnyType.getDescription()); assertNotEquals(null, bunnyType.getValue("IntenselyCute")); assertFalse(bunnyType.getValue("IntenselyCute").isDeprecated()); assertFalse(bunnyType.getValue("ADORABLE").isDeprecated()); assertEquals("Thoroughly adorable", bunnyType.getValue("ADORABLE").getDescription()); assertTrue(bunnyType.getValue("MEH").isDeprecated()); assertEquals("Impossible", bunnyType.getValue("MEH").getDeprecationReason()); assertEquals(respectJavaDeprecation, bunnyType.getValue("AVERAGE").isDeprecated()); if (respectJavaDeprecation) { assertEquals("Deprecated", bunnyType.getValue("AVERAGE").getDeprecationReason()); } assertFalse(bunnyType.getValue("Omg").isDeprecated()); }
Example 3
Source File: GraphQLInlineFragmentPsiElement.java From js-graphql-intellij-plugin with MIT License | 6 votes |
@Override public GraphQLType getTypeScope() { final GraphQLSchema schema = GraphQLTypeDefinitionRegistryServiceImpl.getService(getProject()).getSchema(this); if (schema != null) { if(getTypeCondition() != null) { final GraphQLTypeName typeName = getTypeCondition().getTypeName(); if(typeName != null) { return schema.getType(typeName.getText()); } } else { // inline fragment without type condition, e.g. to add conditional directive, so just return the type from the parent scope final GraphQLTypeScopeProvider parentTypeScopeProvider = PsiTreeUtil.getParentOfType(this, GraphQLTypeScopeProvider.class); if(parentTypeScopeProvider != null) { return parentTypeScopeProvider.getTypeScope(); } } } return null; }
Example 4
Source File: FederationTest.java From federation-jvm with MIT License | 5 votes |
@Test void testEmpty() { final GraphQLSchema federated = Federation.transform(emptySDL) .build(); Assertions.assertEquals("directive @extends on OBJECT | INTERFACE\n" + "\n" + "directive @external on FIELD_DEFINITION\n" + "\n" + "directive @key(fields: _FieldSet!) on OBJECT | INTERFACE\n" + "\n" + "directive @provides(fields: _FieldSet!) on FIELD_DEFINITION\n" + "\n" + "directive @requires(fields: _FieldSet!) on FIELD_DEFINITION\n" + "\n" + "type Query {\n" + " _service: _Service\n" + "}\n" + "\n" + "type _Service {\n" + " sdl: String!\n" + "}\n" + "\n" + "scalar _FieldSet\n", new FederationSdlPrinter(FederationSdlPrinter.Options.defaultOptions() .includeScalarTypes(true) .includeDirectiveDefinitions(def -> !standardDirectives.contains(def.getName())) ).print(federated) ); final GraphQLType _Service = federated.getType("_Service"); assertNotNull(_Service, "_Service type present"); final GraphQLFieldDefinition _service = federated.getQueryType().getFieldDefinition("_service"); assertNotNull(_service, "_service field present"); assertEquals(_Service, _service.getType(), "_service returns _Service"); SchemaUtils.assertSDL(federated, emptySDL); }
Example 5
Source File: GraphQLFragmentDefinitionPsiElement.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@Override public GraphQLType getTypeScope() { final GraphQLSchema schema = GraphQLTypeDefinitionRegistryServiceImpl.getService(getProject()).getSchema(this); if (schema != null) { if(getTypeCondition() != null) { final GraphQLTypeName typeName = getTypeCondition().getTypeName(); if(typeName != null) { return schema.getType(typeName.getText()); } } } return null; }