graphql.language.ScalarTypeDefinition Java Examples
The following examples show how to use
graphql.language.ScalarTypeDefinition.
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: TypeEntry.java From graphql-apigen with Apache License 2.0 | 6 votes |
private static List<Directive> getDirectives(Definition def) { if ( def instanceof ObjectTypeDefinition ) { return ((ObjectTypeDefinition)def).getDirectives(); } if ( def instanceof InterfaceTypeDefinition ) { return ((InterfaceTypeDefinition)def).getDirectives(); } if ( def instanceof EnumTypeDefinition ) { return ((EnumTypeDefinition)def).getDirectives(); } if ( def instanceof ScalarTypeDefinition ) { return ((ScalarTypeDefinition)def).getDirectives(); } if ( def instanceof UnionTypeDefinition ) { return ((UnionTypeDefinition)def).getDirectives(); } if ( def instanceof InputObjectTypeDefinition ) { return ((InputObjectTypeDefinition)def).getDirectives(); } if ( def instanceof SchemaDefinition ) { return ((SchemaDefinition)def).getDirectives(); } return Collections.emptyList(); }
Example #2
Source File: GqlParentType.java From manifold with Apache License 2.0 | 5 votes |
/** * Searches globally for a scalar type i.e., across all .graphql files. */ private ScalarTypeDefinition findScalarTypeDefinition( TypeName type ) { TypeName componentType = (TypeName)getComponentType( type ); ScalarTypeDefinition typeDefinition = _registry.scalars().get( componentType.getName() ); if( typeDefinition != null ) { return typeDefinition; } return _gqlManifold.findScalarTypeDefinition( componentType.getName() ); }
Example #3
Source File: GqlParentType.java From manifold with Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") private String getStartSymbol( Node node ) { String start = ""; if( node instanceof TypeDefinition ) { if( node instanceof ObjectTypeDefinition ) { start = "type"; } else if( node instanceof EnumTypeDefinition ) { start = "enum"; } else if( node instanceof InputObjectTypeDefinition ) { start = "input"; } else if( node instanceof InterfaceTypeDefinition ) { start = "interface"; } else if( node instanceof ScalarTypeDefinition ) { start = "scalar"; } else if( node instanceof UnionTypeDefinition ) { start = "union"; } } else if( node instanceof OperationDefinition ) { start = ((OperationDefinition)node).getOperation().name().toLowerCase(); } return start; }
Example #4
Source File: GqlParentType.java From manifold with Apache License 2.0 | 5 votes |
private String getJavaClassName( SrcLinkedClass owner, TypeName type, boolean boxed ) { ScalarTypeDefinition scalarType = findScalarTypeDefinition( type ); if( scalarType == null ) { // not a scalar type, therefore it must be a 'type' return makeIdentifier( owner.getDisambiguatedNameInNest( type.getName() ), false ); } Class<?> cls = getJavaClass( type, boxed ); return cls == null ? scalarType.getName() : getJavaName( cls ); }
Example #5
Source File: GqlModel.java From manifold with Apache License 2.0 | 5 votes |
private void buildRegistry( Document document ) { TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry(); List<Definition> definitions = document.getDefinitions(); Map<String, OperationDefinition> operations = new LinkedHashMap<>(); Map<String, FragmentDefinition> fragments = new LinkedHashMap<>(); List<GraphQLError> errors = new ArrayList<>(); for( Definition definition: definitions ) { if( definition instanceof SchemaDefinition ) { _schemaDefinition = (SchemaDefinition)definition; } else if( definition instanceof SDLDefinition ) { // types, interfaces, unions, inputs, scalars, extensions typeRegistry.add( (SDLDefinition)definition ).ifPresent( errors::add ); if( definition instanceof ScalarTypeDefinition ) { // register scalar type typeRegistry.scalars().put( ((ScalarTypeDefinition)definition).getName(), (ScalarTypeDefinition)definition ); } } else if( definition instanceof OperationDefinition ) { // queries, mutations, subscriptions operations.put( ((OperationDefinition)definition).getName(), (OperationDefinition)definition ); } else if( definition instanceof FragmentDefinition ) { // fragments fragments.put( ((FragmentDefinition)definition).getName(), (FragmentDefinition)definition ); } } _issues = new GqlIssueContainer( errors, getFile() ); _typeRegistry = typeRegistry; _operations = operations; _fragments = fragments; }
Example #6
Source File: GqlManifold.java From manifold with Apache License 2.0 | 5 votes |
ScalarTypeDefinition findScalarTypeDefinition( String simpleName ) { return getAllTypeNames().stream() .map( fqn -> { GqlModel model = getModel( fqn ); return model == null ? null : model.getScalarTypeDefinition( simpleName ); } ) .filter( Objects::nonNull ) .findFirst().orElse( null ); }
Example #7
Source File: GraphQLIntrospectionResultToSchema.java From js-graphql-intellij-plugin with MIT License | 5 votes |
private TypeDefinition createScalar(Map<String, Object> input) { String name = (String) input.get("name"); if (ScalarInfo.isGraphqlSpecifiedScalar(name)) { return null; } return ScalarTypeDefinition.newScalarTypeDefinition().name(name).description(getDescription(input)).build(); }
Example #8
Source File: GqlModel.java From manifold with Apache License 2.0 | 4 votes |
ScalarTypeDefinition getScalarTypeDefinition( String simpleName ) { return _typeRegistry.scalars().get( simpleName ); }
Example #9
Source File: STModel.java From graphql-apigen with Apache License 2.0 | 4 votes |
public boolean isScalarType() { return typeEntry.getDefinition() instanceof ScalarTypeDefinition; }