当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript graphql-tools.makeExecutableSchema函数代码示例

本文整理汇总了TypeScript中graphql-tools.makeExecutableSchema函数的典型用法代码示例。如果您正苦于以下问题:TypeScript makeExecutableSchema函数的具体用法?TypeScript makeExecutableSchema怎么用?TypeScript makeExecutableSchema使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了makeExecutableSchema函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: makeExecutableSchema

export const initServer = (libs: AppBackendLibs, config: Config) => {
  const schema = makeExecutableSchema({
    resolvers: [
      createAuthenticationsResolvers(libs) as IResolvers,
      createEsValueResolvers() as IResolvers,
      createEventsResolvers(libs) as IResolvers,
      createHostsResolvers(libs) as IResolvers,
      createIpDetailsResolvers(libs) as IResolvers,
      createKpiNetworkResolvers(libs) as IResolvers,
      createNoteResolvers(libs) as IResolvers,
      createPinnedEventResolvers(libs) as IResolvers,
      createSourcesResolvers(libs) as IResolvers,
      createScalarToStringArrayValueResolvers() as IResolvers,
      createOverviewResolvers(libs) as IResolvers,
      createNetworkResolvers(libs) as IResolvers,
      createScalarDateResolvers() as IResolvers,
      createScalarToDateArrayValueResolvers() as IResolvers,
      createScalarToBooleanArrayValueResolvers() as IResolvers,
      createScalarToNumberArrayValueResolvers() as IResolvers,
      createSourcesResolvers(libs) as IResolvers,
      createSourceStatusResolvers(libs) as IResolvers,
      createTimelineResolvers(libs) as IResolvers,
      createUncommonProcessesResolvers(libs) as IResolvers,
      createWhoAmIResolvers() as IResolvers,
      createKpiHostsResolvers(libs) as IResolvers,
    ],
    typeDefs: schemas,
  });

  libs.framework.registerGraphQLEndpoint('/api/siem/graphql', schema);
};
开发者ID:,项目名称:,代码行数:31,代码来源:

示例2: marbles

        marbles(async m => {
          const resolverConfig = makeResolverConfig(m);
          resolverConfig.fetchNodesNetwork = jest
            .fn(resolverConfig.fetchNodesNetwork)
            .mockReturnValue(of({ response: makeFakeNodesNetworkResponse() }));

          const nodesSchema = makeExecutableSchema({
            typeDefs: schemas,
            resolvers: resolvers(resolverConfig)
          });

          const query = gql`
            query {
              networks(privateIPs: $privateIPs) {
                public_ips
              }
            }
          `;

          const output$ = graphqlObservable(query, nodesSchema, {
            privateIPs: ["13.0.6.125", "13.0.6.96", "13.0.1.42"]
          }).pipe(take(1));

          await output$.toPromise();
          expect(resolverConfig.fetchNodesNetwork).toHaveBeenCalledTimes(1);
        })
开发者ID:dcos,项目名称:dcos-ui,代码行数:26,代码来源:NodesNetworkResolver-test.ts

示例3: makeExecutableSchemaWithCacheControlSupport

export function makeExecutableSchemaWithCacheControlSupport(
  options: FirstArg<typeof makeExecutableSchema> & { typeDefs: string },
) {
  return makeExecutableSchema({
    ...options,
    typeDefs: augmentTypeDefsWithCacheControlSupport(options.typeDefs),
  });
}
开发者ID:apollostack,项目名称:apollo-server,代码行数:8,代码来源:cacheControlSupport.ts

示例4: marbles

      marbles(m => {
        const fetchServicePlans = (_service: string) =>
          m.cold("j|", {
            j: {
              code: 200,
              message: "ok",
              response: ["plan-01"]
            }
          });
        const fetchServicePlanDetail = (_service: string, _planName: string) =>
          m.cold("--j|", {
            j: {
              code: 200,
              message: "ok",
              response: makeFakePlanResponse()
            }
          });
        const serviceSchema = makeExecutableSchema({
          typeDefs: schemas,
          resolvers: resolvers({
            fetchServicePlans,
            fetchServicePlanDetail,
            pollingInterval: m.time("--|")
          })
        });

        const query = gql`
          query {
            service(id: $serviceId) {
              id
              plans {
                name
              }
            }
          }
        `;

        const queryResult$ = graphqlObservable(query, serviceSchema, {
          serviceId: "test"
        });

        const expected$ = m.cold("--x-x-(x|)", {
          x: {
            data: {
              service: {
                id: "test",
                plans: [
                  {
                    name: "plan-01"
                  }
                ]
              }
            }
          }
        });

        m.expect(queryResult$.pipe(take(3))).toBeObservable(expected$);
      })
开发者ID:dcos,项目名称:dcos-ui,代码行数:58,代码来源:index-test.ts

示例5: test

test('trace construction', async () => {
  const typeDefs = `
  type User {
    id: Int
    name: String
    posts(limit: Int): [Post]
  }

  type Post {
    id: Int
    title: String
    views: Int
    author: User
  }

  type Query {
    aString: String
    aBoolean: Boolean
    anInt: Int
    author(id: Int): User
    topPosts(limit: Int): [Post]
  }
`;

  const query = `
    query q {
      author(id: 5) {
        name
        posts(limit: 2) {
          id
        }
      }
      aBoolean
    }
`;

  const schema = makeExecutableSchema({ typeDefs });
  addMockFunctionsToSchema({ schema });
  enableGraphQLExtensions(schema);

  const traces: Array<any> = [];
  function addTrace(signature: string, operationName: string, trace: Trace) {
    traces.push({ signature, operationName, trace });
  }
  const reportingExtension = new EngineReportingExtension({}, addTrace);
  const stack = new GraphQLExtensionStack([reportingExtension]);
  const requestDidEnd = stack.requestDidStart({
    request: new Request('http://localhost:123/foo') as any,
    queryString: query,
  });
  await graphql({
    schema,
    source: query,
    contextValue: { _extensionStack: stack },
  });
  requestDidEnd();
  // XXX actually write some tests
});
开发者ID:simonjoom,项目名称:react-native-project,代码行数:58,代码来源:extension.test.ts

示例6: makeExecutableSchema

export const initUptimeServer = (libs: UMServerLibs) => {
  restApiRoutes.forEach(route => libs.framework.registerRoute(createRouteWithAuth(libs, route)));

  const graphQLSchema = makeExecutableSchema({
    resolvers: resolvers.map(createResolversFn => createResolversFn(libs)),
    typeDefs,
  });
  libs.framework.registerGraphQLEndpoint(DEFAULT_GRAPHQL_PATH, graphQLSchema);
};
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:9,代码来源:uptime_server.ts

示例7: getSchema

export default async function getSchema() {
  const files = await globby('typeDefs/*.graphql', { cwd: __dirname })
  const typeDefs = await Promise.all(
    files.map(async file => {
      const buffer = await readFileAsync(path.join(__dirname, file))
      return buffer.toString()
    })
  )

  return makeExecutableSchema({ typeDefs, resolvers })
}
开发者ID:stipsan,项目名称:epic,代码行数:11,代码来源:schema.ts

示例8: require

   folders.forEach(folder => {
     const { resolvers } = require(`../modules/${folder}/resolvers`);
     const typeDefs = importSchema(
       path.join(__dirname, `../modules/${folder}/schema.graphql`)
     );
 
     // Make a schema for each folder in module and store the schema for each folder
     // in the schema array
     schemas.push(
       makeExecutableSchema({ resolvers, typeDefs })
     );
   })
开发者ID:itaygolan,项目名称:GraphQL-Typescript-Server,代码行数:12,代码来源:generateSchema.ts


注:本文中的graphql-tools.makeExecutableSchema函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。