How to use the apollo-graphql.addResolversToSchema function in apollo-graphql

To help you get started, we’ve selected a few apollo-graphql 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 TheBrainFamily / federation-testing-tool / index.js View on Github external
Object.values(serviceMap).forEach(service => {
    let resolvers = {};
    if (service.__addMocks__) {
      Object.entries(mocks).forEach(([type, value]) => {
        resolvers[type] = {
          __resolveReference() {
            return value();
          }
        };
      });
      addResolversToSchema(service.schema, resolvers);
      addMockFunctionsToSchema({
        schema: service.schema,
        preserveResolvers: true,
        mocks
      });
    }
  });
}
github apollographql / apollo-server / packages / apollo-federation / src / service / buildFederatedSchema.ts View on Github external
return undefined;
  });

  schema = transformSchema(schema, type => {
    if (hasEntities && isUnionType(type) && type.name === EntityType.name) {
      return new GraphQLUnionType({
        ...EntityType.toConfig(),
        types: entityTypes.filter(isObjectType),
      });
    }
    return undefined;
  });

  for (const module of modules) {
    if (!module.resolvers) continue;
    addResolversToSchema(schema, module.resolvers);
  }

  return schema;
}