graphql.language.Directive Java Examples
The following examples show how to use
graphql.language.Directive.
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: Directives.java From graphql-spqr with Apache License 2.0 | 5 votes |
private Map<String, Object> parseDirective(Directive dir, DataFetchingEnvironment env) { GraphQLDirective directive = env.getGraphQLSchema().getDirective(dir.getName()); if (directive == null) { return null; } return Collections.unmodifiableMap( valuesResolver.getArgumentValues(env.getGraphQLSchema().getCodeRegistry(), directive.getArguments(), dir.getArguments(), env.getVariables())); }
Example #3
Source File: TypeEntry.java From graphql-apigen with Apache License 2.0 | 5 votes |
private static String getPackageName(List<Directive> directives, String defaultPackageName) { String packageName = null; for ( Directive directive : directives ) { if ( ! "java".equals(directive.getName()) ) continue; for ( Argument arg : directive.getArguments() ) { if ( ! "package".equals(arg.getName()) ) continue; packageName = (String)Scalars.GraphQLString.getCoercing().parseLiteral(arg.getValue()); break; } break; } return ( null == packageName ) ? defaultPackageName : packageName; }
Example #4
Source File: GraphQLIntrospectionResultToSchema.java From js-graphql-intellij-plugin with MIT License | 5 votes |
private List<Directive> createDeprecatedDirective(Map<String, Object> field) { if ((Boolean) field.get("isDeprecated")) { String reason = (String) field.get("deprecationReason"); if (reason == null) { reason = "No longer supported"; // default according to spec } Argument reasonArg = new Argument("reason", new StringValue(reason)); return Collections.singletonList(new Directive("deprecated", Collections.singletonList(reasonArg))); } return Collections.emptyList(); }
Example #5
Source File: Directives.java From graphql-spqr with Apache License 2.0 | 4 votes |
private Map<String, List<Map<String, Object>>> parseDirectives(List<Directive> directives, DataFetchingEnvironment env) { return directives.stream().collect( Collectors.groupingBy(Directive::getName, Collectors.mapping(dir -> parseDirective(dir, env), Collectors.toList()))); }
Example #6
Source File: Directives.java From graphql-spqr with Apache License 2.0 | 4 votes |
List<Directive> getInlineFragmentDirs() { return inlineFragmentDirs; }
Example #7
Source File: Directives.java From graphql-spqr with Apache License 2.0 | 4 votes |
List<Directive> getFragmentDirs() { return fragmentDirs; }
Example #8
Source File: Directives.java From graphql-spqr with Apache License 2.0 | 4 votes |
List<Directive> getFragmentDefDirs() { return fragmentDefDirs; }