graphql.schema.visibility.GraphqlFieldVisibility Java Examples
The following examples show how to use
graphql.schema.visibility.GraphqlFieldVisibility.
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: Bootstrap.java From smallrye-graphql with Apache License 2.0 | 6 votes |
/** * This can hide certain fields in the schema (for security purposes) * * @return The visibility * @see www.graphql-java.com/documentation/v15/fieldvisibility/ */ private GraphqlFieldVisibility getGraphqlFieldVisibility() { if (config != null) { String fieldVisibility = config.getFieldVisibility(); if (fieldVisibility != null && !fieldVisibility.isEmpty() && fieldVisibility.equals(Config.FIELD_VISIBILITY_NO_INTROSPECTION)) { return NO_INTROSPECTION_FIELD_VISIBILITY; } else { String[] patterns = fieldVisibility.split(COMMA); BlockedFields.Builder blockedFields = BlockedFields.newBlock(); for (String pattern : patterns) { blockedFields = blockedFields.addPattern(pattern); } return blockedFields.build(); } } return DEFAULT_FIELD_VISIBILITY; }
Example #2
Source File: Glitr.java From glitr with MIT License | 6 votes |
public Glitr(TypeRegistry typeRegistry, GraphQLCodeRegistry.Builder codeRegistryBuilder, Class queryRoot, @Nullable GraphqlFieldVisibility fieldVisibility, @Nullable ObjectMapper objectMapper, @Nullable RelayHelper relayHelper, @Nullable Class mutationRoot, @Nullable Class subscriptionRoot, @Nullable QueryComplexityCalculator queryComplexityCalculator) { this.codeRegistryBuilder = assertNotNull(codeRegistryBuilder, "codeRegistryBuilder can't be null"); this.typeRegistry = assertNotNull(typeRegistry, "TypeRegistry can't be null"); assertNotNull(queryRoot, "queryRoot class can't be null"); this.relayHelper = relayHelper; Glitr.objectMapper = objectMapper; this.schema = buildSchema(queryRoot, mutationRoot, subscriptionRoot, fieldVisibility); if (nonNull(queryComplexityCalculator)) { this.queryComplexityCalculator = queryComplexityCalculator.withSchema(this.schema); } }
Example #3
Source File: FederationSdlPrinter.java From federation-jvm with MIT License | 5 votes |
/** * This can print an in memory GraphQL schema back to a logical schema definition * * @param schema the schema in play * @return the logical schema definition */ public String print(GraphQLSchema schema) { StringWriter sw = new StringWriter(); PrintWriter out = new PrintWriter(sw); GraphqlFieldVisibility visibility = schema.getCodeRegistry().getFieldVisibility(); printer(schema.getClass()).print(out, schema, visibility); List<GraphQLType> typesAsList = schema.getAllTypesAsList() .stream() .sorted(Comparator.comparing(GraphQLNamedType::getName)) .filter(options.getIncludeTypeDefinition()) .collect(toList()); printType(out, typesAsList, GraphQLInterfaceType.class, visibility); printType(out, typesAsList, GraphQLUnionType.class, visibility); printType(out, typesAsList, GraphQLObjectType.class, visibility); printType(out, typesAsList, GraphQLEnumType.class, visibility); printType(out, typesAsList, GraphQLScalarType.class, visibility); printType(out, typesAsList, GraphQLInputObjectType.class, visibility); String result = sw.toString(); if (result.endsWith("\n\n")) { result = result.substring(0, result.length() - 1); } return result; }
Example #4
Source File: FederationSdlPrinter.java From federation-jvm with MIT License | 5 votes |
@SuppressWarnings("unchecked") private void printType(PrintWriter out, List<GraphQLType> typesAsList, Class typeClazz, GraphqlFieldVisibility visibility) { typesAsList.stream() .filter(type -> typeClazz.isAssignableFrom(type.getClass())) .forEach(type -> printType(out, type, visibility)); }
Example #5
Source File: Glitr.java From glitr with MIT License | 5 votes |
public Glitr(TypeRegistry typeRegistry, GraphQLCodeRegistry.Builder codeRegistryBuilder, Class queryRoot, @Nullable GraphqlFieldVisibility fieldVisibility, @Nullable ObjectMapper objectMapper, @Nullable Class mutationRoot, @Nullable Class subscriptionRoot, @Nullable QueryComplexityCalculator queryComplexityCalculator) { this(typeRegistry, codeRegistryBuilder, queryRoot, fieldVisibility, objectMapper, null, mutationRoot, subscriptionRoot, queryComplexityCalculator); }
Example #6
Source File: FederationSdlPrinter.java From federation-jvm with MIT License | 4 votes |
private void printType(PrintWriter out, GraphQLType type, GraphqlFieldVisibility visibility) { TypePrinter<Object> printer = printer(type.getClass()); printer.print(out, type, visibility); }
Example #7
Source File: GlitrBuilder.java From glitr with MIT License | 4 votes |
public GlitrBuilder withFieldVisibility(GraphqlFieldVisibility fieldVisibility) { this.fieldVisibility = fieldVisibility; return this; }
Example #8
Source File: Glitr.java From glitr with MIT License | 4 votes |
public GraphQLSchema reloadSchema(Class queryRoot, Class mutationRoot, Class subscriptionRoot, GraphqlFieldVisibility fieldVisibility) { this.schema = buildSchema(queryRoot, mutationRoot, subscriptionRoot, fieldVisibility); return this.schema; }
Example #9
Source File: FederationSdlPrinter.java From federation-jvm with MIT License | votes |
void print(PrintWriter out, T type, GraphqlFieldVisibility visibility);