I have a query that is working in the GraphiQL UI :
query GetBreadcrumb($datasource: String!) {
datasource(value: $datasource) {
...mySelectedFields
parent {
...mySelectedFields
parent {
...mySelectedFields
parent {
...mySelectedFields
parent {
...mySelectedFields
parent {
...mySelectedFields
}
}
}
}
}
}
}
fragment mySelectedFields on Item {
name
id
displayName
url(options: {disableLanguageEmbedding: true})
... on AppRoute {
pageIndex {
value
}
}
}
I would like to test it on the server in connected mode but when I call my component, the datasource value is not passed and it should have been filled with the object database id as far as I understood (I'm using Integrated mode).
Here is my component definition :
// eslint-disable-next-line no-unused-vars
import { CommonFieldTypes, SitecoreIcon, Manifest } from '@sitecore-jss/sitecore-jss-manifest';
import fs from 'fs';
const query = fs.readFileSync(
'sitecore/definitions/components/GraphQL-Breadcrumb.sitecore.graphql',
'utf8'
);
/**
* Adds the GraphQL-IntegratedDemo component to the disconnected manifest.
* This function is invoked by convention (*.sitecore.js) when 'jss manifest' is run.
* @param {Manifest} manifest Manifest instance to add components to
*/
export default function(manifest) {
manifest.addComponent({
name: 'GraphQL-Breadcrumb',
icon: SitecoreIcon.GraphConnection_directed,
graphQLQuery: query,
fields: [
{ name: 'sample', type: CommonFieldTypes.SingleLineText },
]
});
}
and here is my component code :
import './stylesheet.scss';
import * as React from 'react';
import { Text } from '@sitecore-jss/sitecore-jss-react';
import { Link as RouterLink } from 'react-router-dom';
export interface Field {
value?: string;
editable?: string;
}
export interface GraphQLBreadcrumbProps {
fields: { [ name: string ]: any};
}
export const GraphQLBreadcrumb: React.FunctionComponent<GraphQLBreadcrumbProps> = ({ fields }: GraphQLBreadcrumbProps): JSX.Element => {
console.log(fields);
return (
<div className='GraphQLBreadcrumb-box'>
<p>GraphQL-Breadcrumb Component</p>
</div>
);
};
I would like to know why my datasource is empty in my data. Did I miss a configuration step ?