nexus/tests/__snapshots__/sdlConverter.spec.ts.snap

335 lines
8.3 KiB
Plaintext

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`SDLConverter printEnumTypes 1`] = `
"export const OrderEnum = enumType({
name: \\"OrderEnum\\",
members: [\\"ASC\\",\\"DESC\\"],
});
export const SomeEnum = enumType({
name: \\"SomeEnum\\",
members: [\\"A\\",{\\"name\\":\\"B\\",\\"deprecation\\":\\"This is a deprecation reason for B\\",\\"value\\":\\"B\\"}],
});"
`;
exports[`SDLConverter printObjectTypes 1`] = `
"export const Mutation = objectType({
name: \\"Mutation\\",
definition(t) {
t.nonNull.list.string(\\"someList\\", {
args: {
items: nonNull(list(stringArg())),
},
})
t.nonNull.field(\\"createPost\\", {
type: Post,
args: {
input: arg({ type: nonNull(CreatePostInput) }),
},
})
t.nonNull.field(\\"registerClick\\", {
type: Query,
args: {
uuid: arg({ type: UUID }),
},
})
}
})
export const Post = objectType({
name: \\"Post\\",
description: \\"This is a description of a Post\\",
definition(t) {
t.implements(Node)
t.nonNull.uuid(\\"uuid\\")
t.nonNull.field(\\"author\\", { type: User })
t.nonNull.list.nonNull.list.nonNull.float(\\"geo\\")
t.list.list.nonNull.float(\\"messyGeo\\")
}
})
export const Query = objectType({
name: \\"Query\\",
definition(t) {
t.nonNull.field(\\"user\\", { type: User })
t.nonNull.list.nonNull.field(\\"posts\\", {
type: Post,
args: {
filters: arg({ type: nonNull(PostFilters) }),
},
})
t.nonNull.field(\\"unionField\\", { type: ExampleUnion })
}
})
export const User = objectType({
name: \\"User\\",
definition(t) {
t.implements(Node)
t.nonNull.string(\\"name\\", {
description: \\"This is a description of a name\\",
args: {
prefix: stringArg({ description: \\"And a description of an arg\\" }),
},
})
t.nonNull.string(\\"email\\")
t.string(\\"phone\\")
t.nonNull.list.nonNull.field(\\"posts\\", {
type: Post,
args: {
filters: arg({ type: PostFilters }),
},
})
t.field(\\"outEnum\\", { type: SomeEnum })
}
})"
`;
exports[`convertSDL 1`] = `
"import { objectType, stringArg, list, nonNull, arg, interfaceType, inputObjectType, unionType, enumType, scalarType } from 'nexus';
export const Mutation = objectType({
name: \\"Mutation\\",
definition(t) {
t.nonNull.list.string(\\"someList\\", {
args: {
items: nonNull(list(stringArg())),
},
})
t.nonNull.field(\\"createPost\\", {
type: Post,
args: {
input: arg({ type: nonNull(CreatePostInput) }),
},
})
t.nonNull.field(\\"registerClick\\", {
type: Query,
args: {
uuid: arg({ type: UUID }),
},
})
}
})
export const Post = objectType({
name: \\"Post\\",
description: \\"This is a description of a Post\\",
definition(t) {
t.implements(Node)
t.nonNull.uuid(\\"uuid\\")
t.nonNull.field(\\"author\\", { type: User })
t.nonNull.list.nonNull.list.nonNull.float(\\"geo\\")
t.list.list.nonNull.float(\\"messyGeo\\")
}
})
export const Query = objectType({
name: \\"Query\\",
definition(t) {
t.nonNull.field(\\"user\\", { type: User })
t.nonNull.list.nonNull.field(\\"posts\\", {
type: Post,
args: {
filters: arg({ type: nonNull(PostFilters) }),
},
})
t.nonNull.field(\\"unionField\\", { type: ExampleUnion })
}
})
export const User = objectType({
name: \\"User\\",
definition(t) {
t.implements(Node)
t.nonNull.string(\\"name\\", {
description: \\"This is a description of a name\\",
args: {
prefix: stringArg({ description: \\"And a description of an arg\\" }),
},
})
t.nonNull.string(\\"email\\")
t.string(\\"phone\\")
t.nonNull.list.nonNull.field(\\"posts\\", {
type: Post,
args: {
filters: arg({ type: PostFilters }),
},
})
t.field(\\"outEnum\\", { type: SomeEnum })
}
})
export const Node = interfaceType({
name: \\"Node\\",
description: \\"This is a description of a Node\\",
definition(t) {
t.nonNull.id(\\"id\\")
}
});
export const CreatePostInput = inputObjectType({
name: \\"CreatePostInput\\",
definition(t) {
t.nonNull.string(\\"name\\")
t.nonNull.id(\\"author\\")
t.nonNull.list.nonNull.list.float(\\"geo\\")
}
});
export const PostFilters = inputObjectType({
name: \\"PostFilters\\",
definition(t) {
t.nonNull.field(\\"order\\", { type: OrderEnum })
t.string(\\"search\\", { default: \\"nexus\\" })
}
});
export const ExampleUnion = unionType({
name: \\"ExampleUnion\\",
definition(t) {
t.members(Post, User)
}
});
export const OrderEnum = enumType({
name: \\"OrderEnum\\",
members: [\\"ASC\\",\\"DESC\\"],
});
export const SomeEnum = enumType({
name: \\"SomeEnum\\",
members: [\\"A\\",{\\"name\\":\\"B\\",\\"deprecation\\":\\"This is a deprecation reason for B\\",\\"value\\":\\"B\\"}],
});
export const UUID = scalarType({
name: \\"UUID\\",
asNexusMethod: \\"uuid\\",
serialize() { /* Todo */ },
parseValue() { /* Todo */ },
parseLiteral() { /* Todo */ }
});"
`;
exports[`convertSDL as commonjs 1`] = `
"const { objectType, stringArg, list, nonNull, arg, interfaceType, inputObjectType, unionType, enumType, scalarType } = require('nexus');
const Mutation = objectType({
name: \\"Mutation\\",
definition(t) {
t.nonNull.list.string(\\"someList\\", {
args: {
items: nonNull(list(stringArg())),
},
})
t.nonNull.field(\\"createPost\\", {
type: Post,
args: {
input: arg({ type: nonNull(CreatePostInput) }),
},
})
t.nonNull.field(\\"registerClick\\", {
type: Query,
args: {
uuid: arg({ type: UUID }),
},
})
}
})
const Post = objectType({
name: \\"Post\\",
description: \\"This is a description of a Post\\",
definition(t) {
t.implements(Node)
t.nonNull.uuid(\\"uuid\\")
t.nonNull.field(\\"author\\", { type: User })
t.nonNull.list.nonNull.list.nonNull.float(\\"geo\\")
t.list.list.nonNull.float(\\"messyGeo\\")
}
})
const Query = objectType({
name: \\"Query\\",
definition(t) {
t.nonNull.field(\\"user\\", { type: User })
t.nonNull.list.nonNull.field(\\"posts\\", {
type: Post,
args: {
filters: arg({ type: nonNull(PostFilters) }),
},
})
t.nonNull.field(\\"unionField\\", { type: ExampleUnion })
}
})
const User = objectType({
name: \\"User\\",
definition(t) {
t.implements(Node)
t.nonNull.string(\\"name\\", {
description: \\"This is a description of a name\\",
args: {
prefix: stringArg({ description: \\"And a description of an arg\\" }),
},
})
t.nonNull.string(\\"email\\")
t.string(\\"phone\\")
t.nonNull.list.nonNull.field(\\"posts\\", {
type: Post,
args: {
filters: arg({ type: PostFilters }),
},
})
t.field(\\"outEnum\\", { type: SomeEnum })
}
})
const Node = interfaceType({
name: \\"Node\\",
description: \\"This is a description of a Node\\",
definition(t) {
t.nonNull.id(\\"id\\")
}
});
const CreatePostInput = inputObjectType({
name: \\"CreatePostInput\\",
definition(t) {
t.nonNull.string(\\"name\\")
t.nonNull.id(\\"author\\")
t.nonNull.list.nonNull.list.float(\\"geo\\")
}
});
const PostFilters = inputObjectType({
name: \\"PostFilters\\",
definition(t) {
t.nonNull.field(\\"order\\", { type: OrderEnum })
t.string(\\"search\\", { default: \\"nexus\\" })
}
});
const ExampleUnion = unionType({
name: \\"ExampleUnion\\",
definition(t) {
t.members(Post, User)
}
});
const OrderEnum = enumType({
name: \\"OrderEnum\\",
members: [\\"ASC\\",\\"DESC\\"],
});
const SomeEnum = enumType({
name: \\"SomeEnum\\",
members: [\\"A\\",{\\"name\\":\\"B\\",\\"deprecation\\":\\"This is a deprecation reason for B\\",\\"value\\":\\"B\\"}],
});
const UUID = scalarType({
name: \\"UUID\\",
asNexusMethod: \\"uuid\\",
serialize() { /* Todo */ },
parseValue() { /* Todo */ },
parseLiteral() { /* Todo */ }
});
exports.Mutation = Mutation;
exports.Post = Post;
exports.Query = Query;
exports.User = User;
exports.Node = Node;
exports.CreatePostInput = CreatePostInput;
exports.PostFilters = PostFilters;
exports.ExampleUnion = ExampleUnion;
exports.OrderEnum = OrderEnum;
exports.SomeEnum = SomeEnum;
exports.UUID = UUID;"
`;