Skip to content

Commit

Permalink
port Fragment.concreteType change to Rust
Browse files Browse the repository at this point in the history
Reviewed By: josephsavona

Differential Revision: D21319739

fbshipit-source-id: ddac044477cf12c2217ad5ff6a069407519821df
  • Loading branch information
kassens authored and facebook-github-bot committed Apr 30, 2020
1 parent 7ad3f0c commit e4dd883
Show file tree
Hide file tree
Showing 80 changed files with 162 additions and 159 deletions.
11 changes: 7 additions & 4 deletions compiler/crates/relay-codegen/src/build_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ impl<'schema, 'builder> CodegenBuilder<'schema, 'builder> {
if plural {
metadata.push((CODEGEN_CONSTANTS.plural, Primitive::Bool(true)))
}
let concrete_type = if self.schema.is_abstract_type(fragment.type_condition) {
Primitive::Null
} else {
Primitive::String(self.schema.get_type_name(fragment.type_condition))
};

// TODO: refetch metadata

let object = vec![
Expand Down Expand Up @@ -250,10 +256,7 @@ impl<'schema, 'builder> CodegenBuilder<'schema, 'builder> {
CODEGEN_CONSTANTS.selections,
self.build_selections(&fragment.selections),
),
(
CODEGEN_CONSTANTS.type_,
Primitive::String(self.schema.get_type_name(fragment.type_condition)),
),
(CODEGEN_CONSTANTS.concrete_type, concrete_type),
];
self.object(object)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ interface ClientNamed {
]
}
],
"type": "User"
"concreteType": "User"
}

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ extend type Page {
"storageKey": null
}
],
"type": "User"
"concreteType": "User"
}

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type ClientUser {
]
}
],
"type": "ClientUser"
"concreteType": "ClientUser"
}

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ interface ClientNamed {
]
}
],
"type": "ClientType"
"concreteType": "ClientType"
}

{
Expand Down Expand Up @@ -221,7 +221,7 @@ interface ClientNamed {
"storageKey": null
}
],
"type": "User"
"concreteType": "User"
}

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ return {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ return {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ return {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ return {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ return {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ return {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,6 @@ return {
"storageKey": null
}
],
"type": "User"
"concreteType": "User"
};
})()
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,5 @@ fragment Example on User {
"storageKey": null
}
],
"type": "User"
"concreteType": "User"
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ return {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,6 @@ return {
"storageKey": null
}
],
"type": "User"
"concreteType": "User"
};
})()
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fragment DeferredFragment on User {
"storageKey": null
}
],
"type": "User"
"concreteType": "User"
}

{
Expand Down Expand Up @@ -72,7 +72,7 @@ fragment DeferredFragment on User {
"storageKey": null
}
],
"type": "User"
"concreteType": "User"
}

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ fragment FeedbackFragment on Feedback {
"storageKey": null
}
],
"type": "Feedback"
"concreteType": "Feedback"
}
Original file line number Diff line number Diff line change
Expand Up @@ -370,5 +370,5 @@ fragment UserFragment on User
"storageKey": null
}
],
"type": "User"
"concreteType": "User"
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,5 @@ interface ClientNamed {
]
}
],
"type": "User"
"concreteType": "User"
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ extend type Page {
]
}
],
"type": "User"
"concreteType": "User"
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ type Foo {
]
}
],
"type": "User"
"concreteType": "User"
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extend type Subscription {
]
}
],
"type": "Mutation"
"concreteType": "Mutation"
},
"kind": "Request",
"operation": {
Expand Down Expand Up @@ -210,7 +210,7 @@ mutation FooMutation(
]
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down Expand Up @@ -342,7 +342,7 @@ query FooQuery(
]
}
],
"type": "Subscription"
"concreteType": "Subscription"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type ClientType {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down Expand Up @@ -185,7 +185,7 @@ fragment Foo_user on User {
]
}
],
"type": "ClientType"
"concreteType": "ClientType"
}

{
Expand Down Expand Up @@ -223,5 +223,5 @@ fragment Foo_user on User {
]
}
],
"type": "User"
"concreteType": "User"
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type ClientType {
]
}
],
"type": "ClientType"
"concreteType": "ClientType"
}

{
Expand Down Expand Up @@ -77,5 +77,5 @@ type ClientType {
]
}
],
"type": "User"
"concreteType": "User"
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface ClientNamed {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down Expand Up @@ -208,5 +208,5 @@ fragment Foo_user on User {
]
}
],
"type": "User"
"concreteType": "User"
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ interface ClientNamed {
]
}
],
"type": "User"
"concreteType": "User"
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,5 @@ extend type FriendsEdge {
]
}
],
"type": "User"
"concreteType": "User"
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ extend type FriendsConnection {
]
}
],
"type": "User"
"concreteType": "User"
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ query CheckinSearchQuery(
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ query TestQueryWithLiteral($latArg: String, $lonArg: String) {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ query TestQuery($date: String) {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ query NodeQuery($id: ID!) {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fragment FeedbackFragment on Feedback
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down Expand Up @@ -362,7 +362,7 @@ fragment FeedbackFragment on Feedback {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down Expand Up @@ -736,5 +736,5 @@ fragment FeedbackFragment_1G22uz on Feedback {
"storageKey": null
}
],
"type": "Feedback"
"concreteType": "Feedback"
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ query NodeQuery($id: ID!) {
"storageKey": null
}
],
"type": "Query"
"concreteType": "Query"
},
"kind": "Request",
"operation": {
Expand Down
Loading

0 comments on commit e4dd883

Please sign in to comment.