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