mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
35d9c059db
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9420 Co-authored-by: Nicolas Beaussart <7281023+beaussan@users.noreply.github.com> GitOrigin-RevId: 31d983ae8573c91ac5bf11066770f776941c3a11
36 lines
924 B
TypeScript
36 lines
924 B
TypeScript
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
|
|
// Node module: openapi-to-graphql
|
|
// This file is licensed under the MIT License.
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
'use strict';
|
|
|
|
import { beforeAll, expect, test } from '@jest/globals';
|
|
import { GraphQLObjectType, GraphQLSchema } from 'graphql';
|
|
|
|
import * as openAPIToGraphQL from '../src/index';
|
|
|
|
// Set up the schema first
|
|
const oas = require('./fixtures/petstore31.json');
|
|
|
|
let createdSchema: GraphQLSchema;
|
|
beforeAll(() => {
|
|
return openAPIToGraphQL
|
|
.createGraphQLSchema(oas, {
|
|
softValidation: true,
|
|
})
|
|
.then(({ schema, report }) => {
|
|
createdSchema = schema;
|
|
})
|
|
.catch(e => {
|
|
console.log(e);
|
|
});
|
|
});
|
|
|
|
test('Petstore 3.1 works', () => {
|
|
const gqlTypes = Object.keys(
|
|
(createdSchema.getTypeMap().Query as GraphQLObjectType).getFields()
|
|
);
|
|
expect(gqlTypes.length).toEqual(2);
|
|
});
|