How to use the feathers-hooks-common.fgraphql function in feathers-hooks-common

To help you get started, we’ve selected a few feathers-hooks-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feathers-plus / generator-feathers-plus / test-expands / a-gens / js / test-hook-unit.test-expected / src1 / services / nedb-1 / nedb-1.populate.js View on Github external
// 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
}
github feathers-plus / generator-feathers-plus / test-expands / a-gens / ts / test-hook-unit.test-expected / src1 / services / nedb-1 / nedb-1.populate.ts View on Github external
// 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;
github feathers-plus / generator-feathers-plus / test-expands / cumulative-1-no-semicolons.test-expected / src1 / services / nedb-1 / nedb-1.populate.js View on Github external
// 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
github feathers-plus / generator-feathers-plus / test-expands / ts-cumulative-1-nedb.test-expected / src1 / services / nedb-2 / nedb-2.populate.ts View on Github external
// 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;
github feathers-plus / generator-feathers-plus / test-expands / cumulative-1-memory.test-expected / src1 / services / nedb-2 / nedb-2.populate.js View on Github external
// 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;
github feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
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: {}
github feathers-plus / generator-feathers-plus / test-expands / cumulative-1-no-semicolons.test-expected / src1 / services / nedb-2 / nedb-2.populate.js View on Github external
// 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
}
github feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
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');