How to use the @graphback/core.filterObjectTypes function in @graphback/core

To help you get started, we’ve selected a few @graphback/core 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 aerogear / graphback / packages / graphback-codegen-schema / src / targetSchemaContext.ts View on Github external
export const createCustomSchemaContext = (inputContext: InputModelTypeContext[]) => {
  const objectTypes = filterObjectTypes(inputContext);

  const queryType = objectTypes.filter((t: InputModelTypeContext) => t.name === 'Query')
  let customQueries = []
  if (queryType.length) {
    customQueries = queryType[0].fields.map(maybeNullFieldArgs)
  }

  const mutationType = objectTypes.filter((t: InputModelTypeContext) => t.name === 'Mutation')
  let customMutations = []
  if (mutationType.length) {
    customMutations = mutationType[0].fields.map(maybeNullFieldArgs)
  }

  const subscriptionType = objectTypes.filter((t: InputModelTypeContext) => t.name === 'Subscription')
  let customSubscriptions = []
  if (subscriptionType.length) {
github aerogear / graphback / packages / graphback-codegen-schema / src / targetSchemaContext.ts View on Github external
})
  });


  const context: TargetContext = {
    types: [],
    interfaces: [],
    inputFields: [],
    filterFields: [],
    queries: [],
    mutations: [],
    subscriptions: [],
    relations
  }

  const objectTypes = filterObjectTypes(inputContext);
  const interfaceTypes = filterInterfaceTypes(inputContext);


  context.types = objectTypes.map((t: InputModelTypeContext) => {
    return {
      "name": t.name,
      "interfaces": t.interfaces.map((i: InputInterfaceType) => i.type),
      "fields": [...t.fields.filter((f: InputModelFieldContext, ) => !f.isType).map(maybeNullField), ...new Set(relations.filter((r: RelationInfo) => r.name === t.name).map((r: RelationInfo) => r.relation))]
    }
  });

  context.interfaces = interfaceTypes.map((t: InputModelTypeContext) => {
    return {
      "name": t.name,
      "fields": [...t.fields.filter((f: InputModelFieldContext, ) => !f.isType).map(maybeNullField), ...new Set(relations.filter((r: RelationInfo) => r.name === t.name).map((r: RelationInfo) => r.relation))]
    }