Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = async (req, res) => {
let queryResponse = await request(GRAPHCOOL_ENDPOINT, recentLinksQuery);
if (queryResponse.error) {
throw new Error('Error fetching links');
}
let linksWithScores = calculateScores(queryResponse.allLinks);
let mutationQuery = generateMutation(linksWithScores);
let mutationResponse = await request(GRAPHCOOL_ENDPOINT, mutationQuery);
if (mutationResponse.error) {
throw new Error('Error updating links');
}
console.log('Updated scores:');
console.log(linksWithScores);
if (req.body) {
// Don't modify the vote record
const event = await json(req);
return event.data;
} else {
return {};
}
};
// id: id,
// duration: youtube.duration,
// year: youtube.year,
// likes: youtube.likes,
// views: youtube.views
// })
// } catch (e) {
// console.log(e)
// }
// })
const js = await json(req)
const video = js.data.Videos.node
try {
const youtube = await getYoutube(video.link)
try {
const update = await request(endpoint, updateDuration, {
id: video.id,
duration: youtube.duration,
year: youtube.year
})
console.log(update)
} catch (e) {
console.log(e)
}
} catch (e) {
console.log(e)
}
return null
}
static async getInitialProps({ req, asPath }) {
const isServer = !!req
if (!isServer) return {}
const data = await request(GRAPHQL_ENDPOINT, schema.pagedTagsRaw, {
filter: queryStringToJSON(asPath),
/* filter: mergeRouteQuery(query), */
/* filter: { page: 2, size: 20 }, */
})
/* eslint-disable */
const { locale, messages } = req || Global.__NEXT_DATA__.props
/* eslint-enable */
const langSetup = {}
langSetup[locale] = messages
return {
langSetup,
/* communities: data.pagedCommunities, */
communitiesContent: { pagedTags: data.pagedTags },
}
// The File API has created a File node. We need to update the URL to
// point to our own endpoint. Unfortunately, we can't, so we use a new
// field on the File Type to store our URL.
const query = `
mutation updateFile($id: ID!, $newUrl: String!) {
updateFile (id: $id, newUrl: $newUrl)
{ name size newUrl id contentType }
}`;
const variables = {
id: result.id,
newUrl: result.url.replace('files.graph.cool', `${req.headers.host}/${webtaskName}`)
};
gqlrequest(graphCoolSimpleEndpoint, query, variables)
.then(data => res.status(200).send(data.updateFile));
});
});
it('responds with "Your account has been disabled."', async () => {
await disable('acb2d923-f3af-479e-9f00-61b12e864666')
await expect(
request(
host,
mutation({
email: 'test@example.org',
password: '1234',
}),
),
).rejects.toThrow('Your account has been disabled.')
})
})
static async profileGraphQL (query, opts = {}) {
opts = Object.assign({ graphqlServer: GRAPHQL_SERVER_URL }, opts)
return graphQLRequest(opts.graphqlServer, query)
}
async getData(report) {
if (report.graphql){
let dataResult = await request("http://localhost:3600/graphql/default/", report.graphql);
let items = dataResult[`${report.object_name}`];
if (items && items.length) {
let processChildren = (item, parentKey, object) => {
/**
把{
"object_name": [{
"_id": "R9HquKmR5fHbDqdWq",
"name": "测试1",
"organization": {
"_id": "P7XMJMjKoSz4yaK49",
"name": "组织A"
}
}]
}
中的organization转成 "organization._id", "organization.name",
转换后结果: {
function requestCupActions() {
const query = `{
getCup(id: 1118) {
actions {
nodes {
time
ratio
}
}
}
}
`
request('https://graphql.makerdao.com/v1', query).then(data => showDataInformation(data))
}
originalRequest(query, variables = {}) {
return request(this.endpoint, query, variables);
}
directives: [],
kind: "OperationDefinition",
operation: "query",
selectionSet: {
kind: "SelectionSet",
selections: querySelections,
},
variableDefinitions,
}];
const query = print({
kind: "Document",
definitions: [...queryDefinition, ...otherDefinitions]
});
return GraphQLDataLoader.dispatchResult(await request(this.endpoint, query, newVariables), separator);
}