1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
macro_rules! impl_set_description {
() => {
/// Set the description
#[inline]
pub fn description(self, description: impl Into<String>) -> Self {
Self {
description: Some(description.into()),
..self
}
}
};
}
macro_rules! impl_set_deprecation {
() => {
/// Set the description
#[inline]
pub fn deprecation(self, reason: Option<&str>) -> Self {
Self {
deprecation: Deprecation::Deprecated {
reason: reason.map(Into::into),
},
..self
}
}
};
}
macro_rules! impl_set_extends {
() => {
/// Indicates that an object or interface definition is an extension of another
/// definition of that same type.
#[inline]
pub fn extends(self) -> Self {
Self {
extends: true,
..self
}
}
};
}
macro_rules! impl_set_inaccessible {
() => {
/// Indicate that an enum is not accessible from a supergraph when using
/// Apollo Federation
///
/// Reference: <https://www.apollographql.com/docs/federation/federated-types/federated-directives/#inaccessible>
#[inline]
pub fn inaccessible(self) -> Self {
Self {
inaccessible: true,
..self
}
}
};
}
macro_rules! impl_set_interface_object {
() => {
/// During composition, the fields of every `@interfaceObject` are added
/// both to their corresponding interface definition and to all
/// entity types that implement that interface.
///
/// Reference: <https://www.apollographql.com/docs/federation/federated-types/federated-directives/#interfaceobject>
#[inline]
pub fn interface_object(self) -> Self {
Self {
interface_object: true,
..self
}
}
};
}
macro_rules! impl_set_tags {
() => {
/// Arbitrary string metadata that will be propagated to the supergraph
/// when using Apollo Federation. This attribute is repeatable
///
/// Reference: <https://www.apollographql.com/docs/federation/federated-types/federated-directives/#applying-metadata>
#[inline]
pub fn tags<I: IntoIterator<Item = T>, T: Into<String>>(self, tags: I) -> Self {
Self {
tags: tags.into_iter().map(Into::into).collect(),
..self
}
}
};
}
macro_rules! impl_set_external {
() => {
/// Mark a field as owned by another service. This allows service A to use
/// fields from service B while also knowing at runtime the types of that
/// field.
#[inline]
pub fn external(self) -> Self {
Self {
external: true,
..self
}
}
};
}
macro_rules! impl_set_requires {
() => {
/// Annotate the required input fieldset from a base type for a resolver. It
/// is used to develop a query plan where the required fields may not be
/// needed by the client, but the service may need additional information
/// from other services.
#[inline]
pub fn requires(self, fields: impl Into<String>) -> Self {
Self {
requires: Some(fields.into()),
..self
}
}
};
}
macro_rules! impl_set_provides {
() => {
/// Annotate the expected returned fieldset from a field on a base type that
/// is guaranteed to be selectable by the gateway.
#[inline]
pub fn provides(self, fields: impl Into<String>) -> Self {
Self {
provides: Some(fields.into()),
..self
}
}
};
}
macro_rules! impl_set_shareable {
() => {
/// Indicate that an object type's field is allowed to be resolved by
/// multiple subgraphs
#[inline]
pub fn shareable(self) -> Self {
Self {
shareable: true,
..self
}
}
};
}
macro_rules! impl_set_override_from {
() => {
/// Indicate that an object type's field is allowed to be resolved by
/// multiple subgraphs
#[inline]
pub fn override_from(self, name: impl Into<String>) -> Self {
Self {
override_from: Some(name.into()),
..self
}
}
};
}