Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fetch: async (variables = {}) =>
(await fetchQuery(context.environment, query, variables))
.TestLogBackgroundWarn,
})
async getEquipmentTypes(): Promise> {
const response = await fetchQuery(RelayEnvironment, equipmentTypesQuery);
return response.equipmentTypes.edges
.map(edge => edge.node)
.filter(Boolean)
.sort((typ1, typ2) => sortLexicographically(typ1.name, typ2.name));
}
ListPosts.getInitialProps = async () => {
const variables = {};
if (initEnvironment && listPostsQuery) {
const { environment, relaySSR } = initEnvironment();
await fetchQuery(environment, listPostsQuery, variables);
const relayData = await relaySSR.getCache();
return {
variables,
relayData
};
}
return {
variables
};
};
fetch: async variables =>
(await fetchQuery(
context.environment,
query,
merge([defaultVariables, variables])
)).ConfigPublic,
})
function fetchChartConfig(path) {
let id = toGlobalId("File", path);
return fetchQuery(modernEnvironment, graphql`
query ParameterRowChartConfigQuery($id: ID!) {
node (id: $id) { id ...on File { yaml } }
}`, {id});
}
async function fetchQuery(...args) {
const [environment] = args;
if (!environment.isRehydrated()) {
await environment.hydrate();
}
return relayFetchQuery(...args);
}
fetch: async variables =>
fetchQuery(
context.environment,
query,
merge([defaultVariables, variables])
),
})
export default async function(req, res, next) {
const environment = getRelayEnvironment();
const data = await fetchQuery(environment, rootQuery, variables);
const renderedComponent = renderToString(
);
res.send(nunjucks.render('index.html', {
renderedComponent: renderedComponent,
records: JSON.stringify(environment.getStore().getSource()),
}));
}
Post.getInitialProps = async ({ query: queryParams }: any) => {
const variables = { slug: queryParams.slug };
if (initEnvironment && postQuery) {
const { environment, relaySSR } = initEnvironment();
await fetchQuery(environment, postQuery, variables);
const relayData = await relaySSR.getCache();
return {
variables,
relayData
};
}
return {
variables
};
};
export const fetchQuery = (query, args) => FQ(environment, query, args);