UNPKG

649 BPlain TextView Raw
1import { renameTransform } from './../src/index';
2import { buildSchema, printSchema } from 'graphql';
3
4describe('rename', () => {
5 const schema = buildSchema(/* GraphQL */ `
6 type Query {
7 user: User!
8 }
9
10 type User {
11 id: ID!
12 }
13 `);
14
15 it('should change the name of a type', async () => {
16 const newSchema = await renameTransform({
17 schema,
18 config: [
19 {
20 from: 'User',
21 to: 'MyUser'
22 }
23 ]
24 });
25
26 expect(newSchema.getType('User')).toBeUndefined();
27 expect(newSchema.getType('MyUser')).toBeDefined();
28 expect(printSchema(newSchema)).toMatchSnapshot();
29 });
30});