pub fn resolve(
        link: Link,
        resolver: Arc<impl LinkResolver>,
    ) -> impl Future<Item = Self, Error = SubgraphManifestResolveError> + Send {
        resolver
            .cat(&link)
            .map_err(SubgraphManifestResolveError::ResolveError)
            .and_then(move |file_bytes| {
                let file = String::from_utf8(file_bytes.to_vec())
                    .map_err(|_| SubgraphManifestResolveError::NonUtf8)?;
                let mut raw: serde_yaml::Value = serde_yaml::from_str(&file)?;
                {
                    let raw_mapping = raw
                        .as_mapping_mut()
                        .ok_or(SubgraphManifestResolveError::InvalidFormat)?;

                    // Inject the IPFS hash as the ID of the subgraph
                    // into the definition.
                    raw_mapping.insert(
                        serde_yaml::Value::from("id"),
                        serde_yaml::Value::from(link.link.trim_start_matches("/ipfs/")),
                    );

                    // Inject the IPFS link as the location of the data
                    // source into the definition
                    raw_mapping.insert(
                        serde_yaml::Value::from("location"),
                        serde_yaml::Value::from(link.link),
                    );
                }
                // Parse the YAML data into an UnresolvedSubgraphManifest
                let unresolved: UnresolvedSubgraphManifest = serde_yaml::from_value(raw)?;
                Ok(unresolved)
            })
            .and_then(move |unresolved| {
                unresolved
                    .resolve(&*resolver)
                    .map_err(SubgraphManifestResolveError::ResolveError)
            })
    }
/// Entry point for resolving a subgraph definition.
/// Right now the only supported links are of the form:
/// `/ipfs/QmUmg7BZC1YP1ca66rRtWKxpXp77WgVHrnv263JtDuvs2k`
Entry point for resolving a subgraph definition.
Right now the only supported links are of the form:
`/ipfs/QmUmg7BZC1YP1ca66rRtWKxpXp77WgVHrnv263JtDuvs2k`
Entry point for resolving a subgraph definition . Right now the only supported links are of the form : ` / ipfs / QmUmg7BZC1YP1ca66rRtWKxpXp77WgVHrnv263JtDuvs2k `
pub fn resolve(
        link: Link,
        resolver: Arc<impl LinkResolver>,
    ) -> impl Future<Item = Self, Error = SubgraphManifestResolveError> + Send {
        resolver
            .cat(&link)
            .map_err(SubgraphManifestResolveError::ResolveError)
            .and_then(move |file_bytes| {
                let file = String::from_utf8(file_bytes.to_vec())
                    .map_err(|_| SubgraphManifestResolveError::NonUtf8)?;
                let mut raw: serde_yaml::Value = serde_yaml::from_str(&file)?;
                {
                    let raw_mapping = raw
                        .as_mapping_mut()
                        .ok_or(SubgraphManifestResolveError::InvalidFormat)?;
                    // Inject the IPFS hash as the ID of the subgraph
                    // into the definition.
                    raw_mapping.insert(
                        serde_yaml::Value::from("id"),
                        serde_yaml::Value::from(link.link.trim_start_matches("/ipfs/")),
                    );
                    // Inject the IPFS link as the location of the data
                    // source into the definition
                    raw_mapping.insert(
                        serde_yaml::Value::from("location"),
                        serde_yaml::Value::from(link.link),
                    );
                }
                // Parse the YAML data into an UnresolvedSubgraphManifest
                let unresolved: UnresolvedSubgraphManifest = serde_yaml::from_value(raw)?;
                Ok(unresolved)
            })
            .and_then(move |unresolved| {
                unresolved
                    .resolve(&*resolver)
                    .map_err(SubgraphManifestResolveError::ResolveError)
            })
    }
pub fn resolve ( link : Link , resolver : Arc < impl LinkResolver > , ) -> impl Future < Item = Self , Error = SubgraphManifestResolveError > + Send { resolver . cat ( & link ) . map_err ( SubgraphManifestResolveError :: ResolveError ) . and_then ( move | file_bytes | { let file = String :: from_utf8 ( file_bytes . to_vec ( ) ) . map_err ( | _ | SubgraphManifestResolveError :: NonUtf8 ) ? ; let mut raw : serde_yaml :: Value = serde_yaml :: from_str ( & file ) ? ; { let raw_mapping = raw . as_mapping_mut ( ) . ok_or ( SubgraphManifestResolveError :: InvalidFormat ) ? ; // Inject the IPFS hash as the ID of the subgraph // into the definition. raw_mapping . insert ( serde_yaml :: Value :: from ( " " ) , serde_yaml :: Value :: from ( link . link . trim_start_matches ( " " ) ) , ) ; // Inject the IPFS link as the location of the data // source into the definition raw_mapping . insert ( serde_yaml :: Value :: from ( " " ) , serde_yaml :: Value :: from ( link . link ) , ) ; } // Parse the YAML data into an UnresolvedSubgraphManifest let unresolved : UnresolvedSubgraphManifest = serde_yaml :: from_value ( raw ) ? ; Ok ( unresolved ) } ) . and_then ( move | unresolved | { unresolved . resolve ( & * resolver ) . map_err ( SubgraphManifestResolveError :: ResolveError ) } ) }
Entry point for resolving a subgraph definition.
Entry point for resolving a subgraph definition .
link
Link
resolver
Arc<impl LinkResolver>
link
Link
resolver
Arc<impl LinkResolver>