Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Example: select query based on user being authenticated or not
({ query, options } = queries[params.user ? queries.foo : queries.bar]);
// Example: select query based on the user role
if (params.user && params.user.roles.includes('foo')) {
({ query, options } = queries.foo);
}
// Example: allow client to provide the query
if (params.$populateQuery) {
({ query, options } = params.$populateQuery);
}
// Populate the data.
const newContext = await fgraphql({
parse,
runTime,
schema,
resolvers,
recordType: 'Nedb1',
query,
options,
})(context);
// Prune and sanitize the data.
// ...
// End the hook.
return newContext;
// !end
}
// Example: select query based on user being authenticated or not
({ query, options, serializer } = queries[params.user ? queries.foo : queries.bar]);
// Example: select query based on the user role
if (params.user && params.user.roles.includes('foo')) {
({ query, options, serializer } = queries.foo);
}
// Example: allow client to provide the query
if (params.$populateQuery) {
({ query, options, serializer } = params.$populateQuery);
}
// Populate the data.
let newContext: any = await fgraphql({
parse,
runTime,
schema,
resolvers,
recordType: 'Nedb1',
query,
options,
})(context);
// Prune and sanitize the data.
if (serializer) {
newContext = serialize(serializer)(newContext);
}
// End the hook.
return newContext;
// Example: select query based on user being authenticated or not
;({ query, options, serializer } = queries[params.user ? queries.foo : queries.bar])
// Example: select query based on the user role
if (params.user && params.user.roles.includes('foo')) {
({ query, options, serializer } = queries.foo)
}
// Example: allow client to provide the query
if (params.$populateQuery) {
({ query, options, serializer } = params.$populateQuery)
}
// Populate the data.
let newContext = await fgraphql({
parse,
runTime,
schema,
resolvers,
recordType: 'Nedb1',
query,
options,
})(context)
// Prune and sanitize the data.
if (serializer) {
newContext = serialize(serializer)(newContext)
}
// End the hook.
return newContext
// Example: select query based on user being authenticated or not
({ query, options, serializer } = queries[params.user ? queries.foo : queries.bar]);
// Example: select query based on the user role
if (params.user && params.user.roles.includes('foo')) {
({ query, options, serializer } = queries.foo);
}
// Example: allow client to provide the query
if (params.$populateQuery) {
({ query, options, serializer } = params.$populateQuery);
}
// Populate the data.
let newContext: any = await fgraphql({
parse,
runTime,
schema,
resolvers,
recordType: 'Nedb2',
query,
options,
})(context);
// Prune and sanitize the data.
if (serializer) {
newContext = serialize(serializer)(newContext);
}
// End the hook.
return newContext;
// Example: select query based on user being authenticated or not
({ query, options, serializer } = queries[params.user ? queries.foo : queries.bar]);
// Example: select query based on the user role
if (params.user && params.user.roles.includes('foo')) {
({ query, options, serializer } = queries.foo);
}
// Example: allow client to provide the query
if (params.$populateQuery) {
({ query, options, serializer } = params.$populateQuery);
}
// Populate the data.
let newContext = await fgraphql({
parse,
runTime,
schema,
resolvers,
recordType: 'Nedb2',
query,
options,
})(context);
// Prune and sanitize the data.
if (serializer) {
newContext = serialize(serializer)(newContext);
}
// End the hook.
return newContext;
posts: {},
comments: {},
followed_by: {},
following: {},
likes: {}
},
resolvers: () => ({
Comment: {
author: () => ({}),
likes: () => ({}),
},
Query: {}
})
};
// $ExpectType Hook>
fgraphql(fgraphqlOptions);
const fgraphqlOptions2: FGraphQLHookOptions = {
...fgraphqlOptions,
query: (context: HookContext) => ({
posts: {},
comments: {},
followed_by: {},
following: {},
likes: {}
}),
resolvers: {
Comment: {
author: () => ({}),
likes: () => ({}),
},
Query: {}
// Example: select query based on user being authenticated or not
;({ query, options } = queries[params.user ? queries.foo : queries.bar])
// Example: select query based on the user role
if (params.user && params.user.roles.includes('foo')) {
({ query, options } = queries.foo)
}
// Example: allow client to provide the query
if (params.$populateQuery) {
({ query, options } = params.$populateQuery)
}
// Populate the data.
const newContext = await fgraphql({
parse,
runTime,
schema,
resolvers,
recordType: 'Nedb2',
query,
options,
})(context)
// Prune and sanitize the data.
// ...
// End the hook.
return newContext
// !end
}
author: () => ({}),
likes: () => ({}),
},
Query: {}
},
options: {
extraAuthProps: ['asdf'],
inclAllFields: false,
inclJoinedNames: false,
inclAllFieldsClient: true,
inclAllFieldsServer: true,
skipHookWhen: (context) => { context.data; return false; }
}
};
// $ExpectType Hook>
fgraphql(fgraphqlOptions2);
// $ExpectType any
getItems(context1);
// $ExpectType SyncContextFunction
isProvider();
// $ExpectType Hook>
keep('abc', 'def');
// $ExpectType Hook>
keepInArray('array', ['fieldName', 'fieldName']);
// $ExpectType Hook>
keepQuery('name', 'address.city');