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(); }
@Override public ScalarTypeDefinition deepCopy() { return new ScalarTypeDefinition(name, deepCopy(directives), description, getSourceLocation(), getComments(), getIgnoredChars()); }
private TypeDefinition createScalar(Map<String, Object> input) { String name = (String) input.get("name"); if (ScalarInfo.isStandardScalar(name)) { return null; } return ScalarTypeDefinition.newScalarTypeDefinition().name(name).build(); }
@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 NodePrinter<ScalarTypeDefinition> scalarTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "scalar", node.getName(), directives(node.getDirectives()))); }; }
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 List<ScalarTypeExtensionDefinition> scalarTypeExtensions(ScalarTypeDefinition typeDefinition, BuildContext buildCtx) { return nvl(buildCtx.typeRegistry.scalarTypeExtensions().get(typeDefinition.getName())); }
@Override public ScalarTypeDefinition withNewChildren(NodeChildrenContainer newChildren) { return transform(builder -> builder .directives(newChildren.getChildren(CHILD_DIRECTIVES)) ); }
public ScalarTypeDefinition build() { ScalarTypeDefinition scalarTypeDefinition = new ScalarTypeDefinition(name, directives, description, sourceLocation, comments, ignoredChars); return scalarTypeDefinition; } }
} else if (descriptionHolder instanceof GraphQLScalarType) { GraphQLScalarType type = (GraphQLScalarType) descriptionHolder; return descriptionAndComments(type::getDescription, type::getDefinition, () -> type.getDefinition().getDescription()); } else if (descriptionHolder instanceof GraphQLArgument) { GraphQLArgument type = (GraphQLArgument) descriptionHolder;
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); }
@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); }
public void remove(SDLDefinition definition) { assertNotNull("definition to remove can't be null"); if (definition instanceof ObjectTypeExtensionDefinition) { removeFromList(objectTypeExtensions, (TypeDefinition) definition); } else if (definition instanceof InterfaceTypeExtensionDefinition) { removeFromList(interfaceTypeExtensions, (TypeDefinition) definition); } else if (definition instanceof UnionTypeExtensionDefinition) { removeFromList(unionTypeExtensions, (TypeDefinition) definition); } else if (definition instanceof EnumTypeExtensionDefinition) { removeFromList(enumTypeExtensions, (TypeDefinition) definition); } else if (definition instanceof ScalarTypeExtensionDefinition) { removeFromList(scalarTypeExtensions, (TypeDefinition) definition); } else if (definition instanceof InputObjectTypeExtensionDefinition) { removeFromList(inputObjectTypeExtensions, (TypeDefinition) definition); } else if (definition instanceof ScalarTypeDefinition) { scalarTypes.remove(((ScalarTypeDefinition) definition).getName()); } else if (definition instanceof TypeDefinition) { types.remove(((TypeDefinition) definition).getName()); } else if (definition instanceof DirectiveDefinition) { directiveDefinitions.remove(((DirectiveDefinition) definition).getName()); } else if (definition instanceof SchemaDefinition) { schema = null; } else { Assert.assertShouldNeverHappen(); } }
@Override public ScalarTypeDefinition withNewChildren(NodeChildrenContainer newChildren) { return transform(builder -> builder .directives(newChildren.getChildren(CHILD_DIRECTIVES)) ); }
public ScalarTypeDefinition build() { ScalarTypeDefinition scalarTypeDefinition = new ScalarTypeDefinition(name, directives, description, sourceLocation, comments, ignoredChars); return scalarTypeDefinition; } }
} else if (descriptionHolder instanceof GraphQLScalarType) { GraphQLScalarType type = (GraphQLScalarType) descriptionHolder; return descriptionAndComments(type::getDescription, type::getDefinition, () -> type.getDefinition().getDescription()); } else if (descriptionHolder instanceof GraphQLArgument) { GraphQLArgument type = (GraphQLArgument) descriptionHolder;
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(); }
@Override public ScalarTypeDefinition deepCopy() { return new ScalarTypeDefinition(name, deepCopy(directives), description, getSourceLocation(), getComments(), getIgnoredChars()); }
private NodePrinter<ScalarTypeDefinition> scalarTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "scalar", node.getName(), directives(node.getDirectives()))); }; }
protected ScalarTypeDefinition createScalarTypeDefinition(GraphqlParser.ScalarTypeDefinitionContext ctx) { ScalarTypeDefinition.Builder def = ScalarTypeDefinition.newScalarTypeDefinition(); def.name(ctx.name().getText()); addCommonData(def, ctx); def.description(newDescription(ctx.description())); def.directives(createDirectives(ctx.directives())); return def.build(); }