get rid of unnecessary list types
This commit is contained in:
@@ -1,47 +1,20 @@
|
|||||||
type House implements Node {
|
type House implements Node {
|
||||||
id: ID!
|
id: ID!
|
||||||
name: String!
|
name: String!
|
||||||
power_data(after: String, first: Int, before: String, last: Int): PowerDatumConnection
|
power_data(after: String, first: Int, before: String, last: Int): [PowerDatum]
|
||||||
habitants(after: String, first: Int, before: String, last: Int): UserConnection
|
habitants(after: String, first: Int, before: String, last: Int): [User]
|
||||||
}
|
|
||||||
|
|
||||||
type HouseConnection {
|
|
||||||
pageInfo: PageInfo!
|
|
||||||
edges: [HouseEdge]
|
|
||||||
}
|
|
||||||
|
|
||||||
type HouseEdge {
|
|
||||||
node: House
|
|
||||||
cursor: String!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Node {
|
interface Node {
|
||||||
id: ID!
|
id: ID!
|
||||||
}
|
}
|
||||||
|
|
||||||
type PageInfo {
|
|
||||||
hasNextPage: Boolean!
|
|
||||||
hasPreviousPage: Boolean!
|
|
||||||
startCursor: String
|
|
||||||
endCursor: String
|
|
||||||
}
|
|
||||||
|
|
||||||
type PowerDatum implements Node {
|
type PowerDatum implements Node {
|
||||||
id: ID!
|
id: ID!
|
||||||
power: Float
|
power: Float
|
||||||
time: Int
|
time: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
type PowerDatumConnection {
|
|
||||||
pageInfo: PageInfo!
|
|
||||||
edges: [PowerDatumEdge]
|
|
||||||
}
|
|
||||||
|
|
||||||
type PowerDatumEdge {
|
|
||||||
node: PowerDatum
|
|
||||||
cursor: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
node(id: ID!): Node
|
node(id: ID!): Node
|
||||||
viewer: User
|
viewer: User
|
||||||
@@ -50,15 +23,5 @@ type Query {
|
|||||||
type User implements Node {
|
type User implements Node {
|
||||||
id: ID!
|
id: ID!
|
||||||
username: String!
|
username: String!
|
||||||
house: HouseConnection
|
house: House
|
||||||
}
|
|
||||||
|
|
||||||
type UserConnection {
|
|
||||||
pageInfo: PageInfo!
|
|
||||||
edges: [UserEdge]
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserEdge {
|
|
||||||
node: User
|
|
||||||
cursor: String!
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,9 +193,13 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"type": {
|
"type": {
|
||||||
"kind": "OBJECT",
|
"kind": "LIST",
|
||||||
"name": "PowerDatumConnection",
|
"name": null,
|
||||||
"ofType": null
|
"ofType": {
|
||||||
|
"kind": "OBJECT",
|
||||||
|
"name": "PowerDatum",
|
||||||
|
"ofType": null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
@@ -246,9 +250,13 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"type": {
|
"type": {
|
||||||
"kind": "OBJECT",
|
"kind": "LIST",
|
||||||
"name": "UserConnection",
|
"name": null,
|
||||||
"ofType": null
|
"ofType": {
|
||||||
|
"kind": "OBJECT",
|
||||||
|
"name": "User",
|
||||||
|
"ofType": null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
@@ -285,165 +293,6 @@
|
|||||||
"enumValues": null,
|
"enumValues": null,
|
||||||
"possibleTypes": null
|
"possibleTypes": null
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "PowerDatumConnection",
|
|
||||||
"description": "A connection to a list of items.",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"name": "pageInfo",
|
|
||||||
"description": "Information to aid in pagination.",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "NON_NULL",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "PageInfo",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "edges",
|
|
||||||
"description": "Information to aid in pagination.",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "LIST",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "PowerDatumEdge",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"inputFields": null,
|
|
||||||
"interfaces": [],
|
|
||||||
"enumValues": null,
|
|
||||||
"possibleTypes": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "PageInfo",
|
|
||||||
"description": "Information about pagination in a connection.",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"name": "hasNextPage",
|
|
||||||
"description": "When paginating forwards, are there more items?",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "NON_NULL",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "SCALAR",
|
|
||||||
"name": "Boolean",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "hasPreviousPage",
|
|
||||||
"description": "When paginating backwards, are there more items?",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "NON_NULL",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "SCALAR",
|
|
||||||
"name": "Boolean",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "startCursor",
|
|
||||||
"description": "When paginating backwards, the cursor to continue.",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "SCALAR",
|
|
||||||
"name": "String",
|
|
||||||
"ofType": null
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "endCursor",
|
|
||||||
"description": "When paginating forwards, the cursor to continue.",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "SCALAR",
|
|
||||||
"name": "String",
|
|
||||||
"ofType": null
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"inputFields": null,
|
|
||||||
"interfaces": [],
|
|
||||||
"enumValues": null,
|
|
||||||
"possibleTypes": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"kind": "SCALAR",
|
|
||||||
"name": "Boolean",
|
|
||||||
"description": "The `Boolean` scalar type represents `true` or `false`.",
|
|
||||||
"fields": null,
|
|
||||||
"inputFields": null,
|
|
||||||
"interfaces": null,
|
|
||||||
"enumValues": null,
|
|
||||||
"possibleTypes": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "PowerDatumEdge",
|
|
||||||
"description": "An edge in a connection.",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"name": "node",
|
|
||||||
"description": "The item at the end of the edge",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "PowerDatum",
|
|
||||||
"ofType": null
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cursor",
|
|
||||||
"description": "A cursor for use in pagination",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "NON_NULL",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "SCALAR",
|
|
||||||
"name": "String",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"inputFields": null,
|
|
||||||
"interfaces": [],
|
|
||||||
"enumValues": null,
|
|
||||||
"possibleTypes": null
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"kind": "OBJECT",
|
"kind": "OBJECT",
|
||||||
"name": "PowerDatum",
|
"name": "PowerDatum",
|
||||||
@@ -511,88 +360,6 @@
|
|||||||
"enumValues": null,
|
"enumValues": null,
|
||||||
"possibleTypes": null
|
"possibleTypes": null
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "UserConnection",
|
|
||||||
"description": "A connection to a list of items.",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"name": "pageInfo",
|
|
||||||
"description": "Information to aid in pagination.",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "NON_NULL",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "PageInfo",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "edges",
|
|
||||||
"description": "Information to aid in pagination.",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "LIST",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "UserEdge",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"inputFields": null,
|
|
||||||
"interfaces": [],
|
|
||||||
"enumValues": null,
|
|
||||||
"possibleTypes": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "UserEdge",
|
|
||||||
"description": "An edge in a connection.",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"name": "node",
|
|
||||||
"description": "The item at the end of the edge",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "User",
|
|
||||||
"ofType": null
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cursor",
|
|
||||||
"description": "A cursor for use in pagination",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "NON_NULL",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "SCALAR",
|
|
||||||
"name": "String",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"inputFields": null,
|
|
||||||
"interfaces": [],
|
|
||||||
"enumValues": null,
|
|
||||||
"possibleTypes": null
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"kind": "OBJECT",
|
"kind": "OBJECT",
|
||||||
"name": "User",
|
"name": "User",
|
||||||
@@ -636,7 +403,7 @@
|
|||||||
"args": [],
|
"args": [],
|
||||||
"type": {
|
"type": {
|
||||||
"kind": "OBJECT",
|
"kind": "OBJECT",
|
||||||
"name": "HouseConnection",
|
"name": "House",
|
||||||
"ofType": null
|
"ofType": null
|
||||||
},
|
},
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
@@ -654,88 +421,6 @@
|
|||||||
"enumValues": null,
|
"enumValues": null,
|
||||||
"possibleTypes": null
|
"possibleTypes": null
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "HouseConnection",
|
|
||||||
"description": "A connection to a list of items.",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"name": "pageInfo",
|
|
||||||
"description": "Information to aid in pagination.",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "NON_NULL",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "PageInfo",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "edges",
|
|
||||||
"description": "Information to aid in pagination.",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "LIST",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "HouseEdge",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"inputFields": null,
|
|
||||||
"interfaces": [],
|
|
||||||
"enumValues": null,
|
|
||||||
"possibleTypes": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "HouseEdge",
|
|
||||||
"description": "An edge in a connection.",
|
|
||||||
"fields": [
|
|
||||||
{
|
|
||||||
"name": "node",
|
|
||||||
"description": "The item at the end of the edge",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "OBJECT",
|
|
||||||
"name": "House",
|
|
||||||
"ofType": null
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "cursor",
|
|
||||||
"description": "A cursor for use in pagination",
|
|
||||||
"args": [],
|
|
||||||
"type": {
|
|
||||||
"kind": "NON_NULL",
|
|
||||||
"name": null,
|
|
||||||
"ofType": {
|
|
||||||
"kind": "SCALAR",
|
|
||||||
"name": "String",
|
|
||||||
"ofType": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"isDeprecated": false,
|
|
||||||
"deprecationReason": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"inputFields": null,
|
|
||||||
"interfaces": [],
|
|
||||||
"enumValues": null,
|
|
||||||
"possibleTypes": null
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"kind": "OBJECT",
|
"kind": "OBJECT",
|
||||||
"name": "__Schema",
|
"name": "__Schema",
|
||||||
@@ -1077,6 +762,16 @@
|
|||||||
],
|
],
|
||||||
"possibleTypes": null
|
"possibleTypes": null
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "Boolean",
|
||||||
|
"description": "The `Boolean` scalar type represents `true` or `false`.",
|
||||||
|
"fields": null,
|
||||||
|
"inputFields": null,
|
||||||
|
"interfaces": null,
|
||||||
|
"enumValues": null,
|
||||||
|
"possibleTypes": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"kind": "OBJECT",
|
"kind": "OBJECT",
|
||||||
"name": "__Field",
|
"name": "__Field",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import Relay from 'react-relay';
|
|||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
var viewer = this.props.viewer,
|
var viewer = this.props.viewer,
|
||||||
house = viewer.house.edges[0].node;
|
house = viewer.house;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1>Hi, {viewer.username}</h1>
|
<h1>Hi, {viewer.username}</h1>
|
||||||
@@ -20,11 +20,7 @@ export default Relay.createContainer(App, {
|
|||||||
fragment on User {
|
fragment on User {
|
||||||
username
|
username
|
||||||
house {
|
house {
|
||||||
edges {
|
name
|
||||||
node {
|
|
||||||
name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import {
|
|||||||
GraphQLNonNull,
|
GraphQLNonNull,
|
||||||
GraphQLObjectType,
|
GraphQLObjectType,
|
||||||
GraphQLInt,
|
GraphQLInt,
|
||||||
GraphQLString
|
GraphQLString,
|
||||||
|
GraphQLList
|
||||||
} from 'graphql';
|
} from 'graphql';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -49,16 +50,13 @@ var House = DB.sequelize.define(NAME, {
|
|||||||
name: NAME,
|
name: NAME,
|
||||||
description: 'A house',
|
description: 'A house',
|
||||||
fields: () => {
|
fields: () => {
|
||||||
var {connectionType: power_data_connection} = connectionDefinitions({name: DB.PowerDatum.name, nodeType: DB.PowerDatum.graphql_type}),
|
|
||||||
{connectionType: habitants_connection} = connectionDefinitions({name: DB.User.name, nodeType: DB.User.graphql_type});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: globalIdField(NAME),
|
id: globalIdField(NAME),
|
||||||
name: {
|
name: {
|
||||||
type: new GraphQLNonNull(GraphQLString)
|
type: new GraphQLNonNull(GraphQLString)
|
||||||
},
|
},
|
||||||
power_data: {
|
power_data: {
|
||||||
type: power_data_connection,
|
type: new GraphQLList(DB.PowerDatum.graphql_type),
|
||||||
description: "Returns house's power data.",
|
description: "Returns house's power data.",
|
||||||
args: connectionArgs,
|
args: connectionArgs,
|
||||||
resolve: (house, args) => {
|
resolve: (house, args) => {
|
||||||
@@ -66,7 +64,7 @@ var House = DB.sequelize.define(NAME, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
habitants: {
|
habitants: {
|
||||||
type: habitants_connection,
|
type: new GraphQLList(DB.User.graphql_type),
|
||||||
description: "Returns list of house's habitants.",
|
description: "Returns list of house's habitants.",
|
||||||
args: connectionArgs,
|
args: connectionArgs,
|
||||||
resolve: (house, args) => {
|
resolve: (house, args) => {
|
||||||
|
|||||||
@@ -49,14 +49,13 @@ var User = DB.sequelize.define(NAME, {
|
|||||||
name: NAME,
|
name: NAME,
|
||||||
description: 'A house',
|
description: 'A house',
|
||||||
fields: () => {
|
fields: () => {
|
||||||
var {connectionType: house_connection} = connectionDefinitions({name: DB.House.name, nodeType: DB.House.graphql_type});
|
|
||||||
return {
|
return {
|
||||||
id: globalIdField(NAME),
|
id: globalIdField(NAME),
|
||||||
username: {
|
username: {
|
||||||
type: new GraphQLNonNull(GraphQLString)
|
type: new GraphQLNonNull(GraphQLString)
|
||||||
},
|
},
|
||||||
house: {
|
house: {
|
||||||
type: house_connection,
|
type: DB.House.graphql_type,
|
||||||
description: "Returns user's house.",
|
description: "Returns user's house.",
|
||||||
resolve: (user, args) => {
|
resolve: (user, args) => {
|
||||||
return user.getHouse();
|
return user.getHouse();
|
||||||
|
|||||||
Reference in New Issue
Block a user