當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。