private NodePrinter<ScalarTypeDefinition> scalarTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "scalar", node.getName(), directives(node.getDirectives()))); }; }
@Override public TraversalControl visitScalarTypeDefinition(ScalarTypeDefinition node, TraverserContext<Node> context) { ScalarTypeDefinition changedNode = node.transform(builder -> { List<Directive> directives = sort(node.getDirectives(), comparing(Directive::getName)); builder.directives(directives); }); return changeNode(context, changedNode); }
private Builder(ScalarTypeDefinition existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.name = existing.getName(); this.description = existing.getDescription(); this.directives = existing.getDirectives(); this.ignoredChars = existing.getIgnoredChars(); }
private GraphQLScalarType buildScalar(BuildContext buildCtx, ScalarTypeDefinition typeDefinition) { buildCtx.enterNode(typeDefinition); TypeDefinitionRegistry typeRegistry = buildCtx.getTypeRegistry(); RuntimeWiring runtimeWiring = buildCtx.getWiring(); WiringFactory wiringFactory = runtimeWiring.getWiringFactory(); List<ScalarTypeExtensionDefinition> extensions = scalarTypeExtensions(typeDefinition, buildCtx); ScalarWiringEnvironment environment = new ScalarWiringEnvironment(typeRegistry, typeDefinition, extensions); GraphQLScalarType scalar; if (wiringFactory.providesScalar(environment)) { scalar = wiringFactory.getScalar(environment); } else { scalar = buildCtx.getWiring().getScalars().get(typeDefinition.getName()); } if (!ScalarInfo.isStandardScalar(scalar) && !ScalarInfo.isGraphqlSpecifiedScalar(scalar)) { scalar = scalar.transform(builder -> builder.withDirectives( buildDirectives(typeDefinition.getDirectives(), directivesOf(extensions), SCALAR, buildCtx.getDirectiveDefinitions()) )); // // only allow modification of custom scalars scalar = directiveBehaviour.onScalar(scalar, buildCtx.mkBehaviourParams()); } return buildCtx.exitNode(scalar); }
private NodePrinter<ScalarTypeDefinition> scalarTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "scalar", node.getName(), directives(node.getDirectives()))); }; }
@Override public TraversalControl visitScalarTypeDefinition(ScalarTypeDefinition node, TraverserContext<Node> context) { ScalarTypeDefinition changedNode = node.transform(builder -> { List<Directive> directives = sort(node.getDirectives(), comparing(Directive::getName)); builder.directives(directives); }); return changeNode(context, changedNode); }
private Builder(ScalarTypeDefinition existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.name = existing.getName(); this.description = existing.getDescription(); this.directives = existing.getDirectives(); this.ignoredChars = existing.getIgnoredChars(); }
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(); }
private GraphQLScalarType buildScalar(BuildContext buildCtx, ScalarTypeDefinition typeDefinition) { buildCtx.enterNode(typeDefinition); TypeDefinitionRegistry typeRegistry = buildCtx.getTypeRegistry(); RuntimeWiring runtimeWiring = buildCtx.getWiring(); WiringFactory wiringFactory = runtimeWiring.getWiringFactory(); List<ScalarTypeExtensionDefinition> extensions = scalarTypeExtensions(typeDefinition, buildCtx); ScalarWiringEnvironment environment = new ScalarWiringEnvironment(typeRegistry, typeDefinition, extensions); GraphQLScalarType scalar; if (wiringFactory.providesScalar(environment)) { scalar = wiringFactory.getScalar(environment); } else { scalar = buildCtx.getWiring().getScalars().get(typeDefinition.getName()); } if (!ScalarInfo.isStandardScalar(scalar) && !ScalarInfo.isGraphqlSpecifiedScalar(scalar)) { scalar = scalar.transform(builder -> builder.withDirectives( buildDirectives(typeDefinition.getDirectives(), directivesOf(extensions), SCALAR, buildCtx.getDirectiveDefinitions()) )); // // only allow modification of custom scalars scalar = directiveBehaviour.onScalar(scalar, buildCtx.mkBehaviourParams()); } return buildCtx.exitNode(scalar); }