Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate interface fields #120

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
56 changes: 0 additions & 56 deletions src/InterfaceGraph.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ OUTPUT
-----------------
-- SDL --
interface IPerson {
greeting: String
greeting: String @metadata(argCount: 1, name: "greeting", tsModulePath: "grats/src/tests/fixtures/extend_interface/addStringFieldToInterface.ts")
hello: String @metadata
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ OUTPUT
-----------------
-- SDL --
interface IPerson implements IThing {
greeting: String
greeting: String @metadata(argCount: 1, name: "greeting", tsModulePath: "grats/src/tests/fixtures/extend_interface/addStringFieldToInterfaceImplementedByInterface.ts")
}

interface IThing {
greeting: String
greeting: String @metadata(argCount: 1, name: "greeting", tsModulePath: "grats/src/tests/fixtures/extend_interface/addStringFieldToInterfaceImplementedByInterface.ts")
}

type Admin implements IPerson & IThing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,6 @@ OUTPUT
-----------------
src/tests/fixtures/extend_interface/addStringFieldToInterfaceTwice.invalid.ts:9:17 - error: Field "IPerson.greeting" can only be defined once.

9 export function greeting(person: IPerson): string {
~~~~~~~~

src/tests/fixtures/extend_interface/addStringFieldToInterfaceTwice.invalid.ts:13:5
13 /** @gqlField greeting */
~~~~~~~~~~~~~~~~~~~
Related location
src/tests/fixtures/extend_interface/addStringFieldToInterfaceTwice.invalid.ts:9:17 - error: Field "Admin.greeting" can only be defined once.

9 export function greeting(person: IPerson): string {
~~~~~~~~

src/tests/fixtures/extend_interface/addStringFieldToInterfaceTwice.invalid.ts:13:5
13 /** @gqlField greeting */
~~~~~~~~~~~~~~~~~~~
Related location
src/tests/fixtures/extend_interface/addStringFieldToInterfaceTwice.invalid.ts:9:17 - error: Field "User.greeting" can only be defined once.

9 export function greeting(person: IPerson): string {
~~~~~~~~

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
-----------------
INPUT
-----------------
/** @gqlInterface */
interface IPerson {
name: string;
/** @gqlField */
hello: string;
}

/** @gqlField */
export function greeting(person: IPerson): string {
return `Hello ${person.name}!`;
}

/** @gqlType */
class User implements IPerson {
__typename: "User";
name: string;
/** @gqlField */
hello: string;

/** @gqlField */
greeting(): string {
return `Hello ${this.name}!`;
}
}

-----------------
OUTPUT
-----------------
-- SDL --
interface IPerson {
greeting: String @metadata(argCount: 1, name: "greeting", tsModulePath: "grats/src/tests/fixtures/extend_interface/redefineFiledThatExistsOnConcreteType.ts")
hello: String @metadata
}

type User implements IPerson {
greeting: String @metadata(argCount: 0)
hello: String @metadata
}
-- TypeScript --
import { GraphQLSchema, GraphQLInterfaceType, GraphQLString, GraphQLObjectType } from "graphql";
export function getSchema(): GraphQLSchema {
const IPersonType: GraphQLInterfaceType = new GraphQLInterfaceType({
name: "IPerson",
fields() {
return {
greeting: {
name: "greeting",
type: GraphQLString
},
hello: {
name: "hello",
type: GraphQLString
}
};
}
});
const UserType: GraphQLObjectType = new GraphQLObjectType({
name: "User",
fields() {
return {
greeting: {
name: "greeting",
type: GraphQLString
},
hello: {
name: "hello",
type: GraphQLString
}
};
},
interfaces() {
return [IPersonType];
}
});
return new GraphQLSchema({
types: [IPersonType, UserType]
});
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
-----------------
INPUT
-----------------
/** @gqlInterface */
interface IPerson {
name: string;
/** @gqlField */
hello: string;
}

/** @gqlField */
export function greeting(person: IPerson): string {
return `Hello ${person.name}!`;
}

/** @gqlInterface */
interface User extends IPerson {
__typename: "User";
name: string;
/** @gqlField */
hello: string;

/** @gqlField */
greeting(): string;
}

-----------------
OUTPUT
-----------------
-- SDL --
interface IPerson {
greeting: String @metadata(argCount: 1, name: "greeting", tsModulePath: "grats/src/tests/fixtures/extend_interface/redefineFiledThatExistsOnImplementingInterface.ts")
hello: String @metadata
}

interface User implements IPerson {
greeting: String @metadata(argCount: 0)
hello: String @metadata
}
-- TypeScript --
import { GraphQLSchema, GraphQLInterfaceType, GraphQLString } from "graphql";
export function getSchema(): GraphQLSchema {
const IPersonType: GraphQLInterfaceType = new GraphQLInterfaceType({
name: "IPerson",
fields() {
return {
greeting: {
name: "greeting",
type: GraphQLString
},
hello: {
name: "hello",
type: GraphQLString
}
};
}
});
const UserType: GraphQLInterfaceType = new GraphQLInterfaceType({
name: "User",
fields() {
return {
greeting: {
name: "greeting",
type: GraphQLString
},
hello: {
name: "hello",
type: GraphQLString
}
};
},
interfaces() {
return [IPersonType];
}
});
return new GraphQLSchema({
types: [IPersonType, UserType]
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ OUTPUT
-- SDL --
interface IFoo {
bar: String @metadata
greeting: String
greeting: String @metadata(argCount: 1, name: "greeting", tsModulePath: "grats/src/tests/fixtures/extend_type/interfaceFirstArgumentType.ts")
}

type SomeType {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** @gqlInterface */
interface Entity {
/** @gqlField */
name: string | null;
}

/** @gqlInterface */
interface IThing extends Entity {
name: string | null;
}

/** @gqlType */
export class Doohickey implements IThing, Entity {
__typename: "Doohickey";
name: string;
}
Loading
Loading