Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Added a tool and CLI command to merge schema using @import dependency resolution",
"packageName": "@graphitation/cli",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Added a tool and CLI command to merge schema using @import dependency resolution",
"packageName": "@graphitation/merge-schemas",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Added a tool and CLI command to merge schema using @import dependency resolution",
"packageName": "@graphitation/supermassive",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Added a tool and CLI command to merge schema using @import dependency resolution",
"packageName": "@graphitation/ts-codegen",
"email": "[email protected]",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion packages/cli/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": ["../../.eslintrc.json"],
"extends": ["../../.eslintrc.json", "plugin:@typescript-eslint/recommended"],
"root": true
}
7 changes: 7 additions & 0 deletions packages/cli/bin/graphitation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env node

(function () {
require("@graphitation/cli/lib/graphitation")
.graphitation()
.parseAsync(process.argv);
})();
5 changes: 3 additions & 2 deletions packages/cli/bin/supermassive.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node

(function () {
require("@graphitation/cli/lib/supermassive")
.supermassive()
console.warn("DEPRECATED - use graphitation command");
require("@graphitation/cli/lib/graphitation")
.graphitation()
.parseAsync(process.argv);
})();
2 changes: 2 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"license": "MIT",
"version": "1.5.5",
"bin": {
"graphitation": "./bin/graphitation.js",
"supermassive": "./bin/supermassive.js"
},
"repository": {
Expand All @@ -23,6 +24,7 @@
},
"dependencies": {
"@graphitation/supermassive-extractors": "^2.1.0",
"@graphitation/merge-schemas": "^0.1.0",
"@graphitation/ts-codegen": "^2.4.0",
"commander": "^8.3.0",
"typescript": "^4.4.3 <4.5.0",
Expand Down
82 changes: 82 additions & 0 deletions packages/cli/src/__tests__/__snapshots__/mergeSchemas.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`graphitation complains about missing imports, but allows passing with a flag 1`] = `
"# This file was automatically generated (by @graphitation/cli) and should not be edited.
extend type NonType {
foo: DateTime
}
"
`;

exports[`graphitation generates from glob 1`] = `
"# This file was automatically generated (by @graphitation/cli) and should not be edited.
type Person implements Node {
id: ID!
}

"""ISO8601 Date Time"""
scalar DateTime

"""
Define a type to be compliant with the Global Object Identification best-practice spec.
https://graphql.org/learn/global-object-identification/
"""
interface Node {
id: ID!
}

type Bar implements Node {
id: ID!
}

type Foo implements Node {
id: ID!
timestamp: DateTime
}

type Frobnar implements Node {
id: ID!
}

extend type Person {
foo: Foo
}
"
`;

exports[`graphitation generates from single file 1`] = `
"# This file was automatically generated (by @graphitation/cli) and should not be edited.
type Baz implements Node {
id: ID!
foo: Foo
}

type Person implements Node {
id: ID!
}

"""ISO8601 Date Time"""
scalar DateTime

"""
Define a type to be compliant with the Global Object Identification best-practice spec.
https://graphql.org/learn/global-object-identification/
"""
interface Node {
id: ID!
}

type Bar implements Node {
id: ID!
}

type Foo implements Node {
id: ID!
timestamp: DateTime
}

extend type Person {
foo: Foo
}
"
`;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`supermassive should generate 1`] = `
exports[`graphitation should generate 1`] = `
"import { GraphQLList, GraphQLNonNull, GraphQLID, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean, GraphQLEnumType } from "graphql";
import { Resolvers, UnionTypeResolver, EnumTypeResolver, ObjectTypeResolver, InterfaceTypeResolver } from "@graphitation/supermassive";
const SearchResult: UnionTypeResolver = { __types: ["Person", "Starship", "Transport", "Species", "Vehicle", "Planet", "Film"], __resolveType: undefined };
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extend schema @import(from: "./FoundationalTypes.graphql", defs: ["Node"])

type Person implements Node {
id: ID!
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
"""
@oneOf is a proposed directive currently in RFC stage: https://github.com/graphql/graphql-spec/pull/825
OneOf Input Objects are a special variant of Input Objects where the type system asserts
that exactly one of the fields must be set and non-null, all others being omitted.
Below is a placeholder definition of the directive until it is part of the spec
"""
directive @oneOf on INPUT_OBJECT

type Query {
noop: Boolean # TODO: Needs to be removed during schema merging.
}

type Mutation {
noop: Boolean # TODO: Needs to be removed during schema merging.
}

"""
Define a type to be compliant with the Global Object Identification best-practice spec.
https://graphql.org/learn/global-object-identification/
"""
interface Node {
id: ID!
}

"""
A type describing a relationship between Nodes.
"""
interface ConnectionEdge {
"""
The Node that this edge points to
"""
node: Node!
}

"""
A ConnectionEdge with Cursor Pagination
"""
interface ConnectionEdgeWithCursorPagination implements ConnectionEdge {
"""
The 'cursor' of this edge in the list of edges,
used to paginate relative to this item when performing
future queries.

See https://graphql.org/learn/pagination/
"""
cursor: String!

"""
The Node that this edge points to
"""
node: Node!
}

"""
The base Connection type.

See https://www.apollographql.com/blog/explaining-graphql-connections-c48b7c3d6976
"""
interface Connection {
"""
Edges to the member nodes of this collection
"""
edges: [ConnectionEdge!]!
}

interface ConnectionWithCursorPagination {
"""
Edges to the member nodes of this collection
"""
edges: [ConnectionEdgeWithCursorPagination!]!

"""
Information about cursors and pagination in the list of
edges above.
"""
pageInfo: PageInfoWithCursorPagination!
}

"""
The Cursor Pagination PageInfo type.

https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo
"""
type PageInfoWithCursorPagination {
"""
True if there is another page after this one
"""
hasNextPage: Boolean!

"""
True if there is another page before this one
"""
hasPreviousPage: Boolean!

"""
Identifier of the first edge in this page
"""
startCursor: String

"""
Identifier of the last edge in this page
"""
endCursor: String
}

interface MutationFailure {
failureCode: String!
"""
Localized error message
"""
errorMessage: String!
}

"""
ISO8601 Date Time
"""
scalar DateTime

scalar Cursor

scalar BigInt
20 changes: 20 additions & 0 deletions packages/cli/src/__tests__/fixtures/mergeSchemas/core.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
extend schema
@import(
from: "./FoundationalTypes"
defs: [
"Query"
"Mutation"
"Subscription"
"Node"
"oneOf"
"ConnectionEdge"
"ConnectionEdgeWithCursorPagination"
"Connection"
"ConnectionWithCursorPagination"
"MutationFailure"
"DateTime"
"Cursor"
"BigInt"
]
)
@import(from: "./FirstClassTypes", defs: ["Person"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extend schema
@import(from: "./test-import", defs: ["Foo", "Bar"], extends: ["Person"])
@import(from: "./core", defs: ["Node", "Person"])

type Baz implements Node {
id: ID!
foo: Foo
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extend type NonType {
foo: DateTime
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extend schema @import(from: "./core", defs: ["Nodeee"])

extend type NonType {
foo: DateTime
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
extend schema @import(from: "./core", defs: ["Node", "DateTime", "Person"])

type Foo implements Node {
id: ID!
timestamp: DateTime
}

type Bar implements Node {
id: ID!
}

extend type Person {
foo: Foo
}

type Frobnar implements Node {
id: ID!
}
Loading