This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
schemaCreator = SchemaCreator() | |
schema = schemaCreator.getSchema() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app = Flask(__name__) | |
@app.route("/", methods=["GET"]) | |
def graphql_playgroud(): | |
return PLAYGROUND_HTML, 200 | |
@app.route("/", methods=["POST"]) | |
def graphql_server(): | |
data = request.get_json() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
federated_gateway: | |
depends_on: | |
- graphql_server_user | |
- graphql_server_photo | |
- graphql_server_review | |
image: xmorse/apollo-federation-gateway | |
ports: | |
- "4000:80" | |
environment: | |
URL_0: "http://graphql_server_user:8300" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query{ | |
users(first_name:"Han"){ | |
id | |
first_name | |
last_name | |
photos{ | |
id | |
url | |
reviews{ | |
id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Query { | |
users(id: ID, first_name: String, last_name: String): [User] | |
} | |
""" | |
User | |
The `User` type | |
""" | |
type User @key(fields: "id"){ | |
id: ID! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Photo { | |
id: ID! | |
url: String! | |
reviews: [Review] | |
} | |
type Query { | |
users(id: ID, first_name: String, last_name: String): [User] | |
photo(id: ID): [Photo] | |
review(id: ID): [Review] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
directive @external on FIELD_DEFINITION | |
directive @requires(fields: _FieldSet!) on FIELD_DEFINITION | |
directive @provides(fields: _FieldSet!) on FIELD_DEFINITION | |
directive @key(fields: _FieldSet!) on OBJECT | INTERFACE | |
directive @extends on OBJECT | |
scalar _Any | |
union _Entity = User |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query = QueryType() | |
user = FederatedObjectType("User") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
manager = FederatedManager( | |
schema_sdl_file='schema/schema.graphql', | |
query=self.query, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@self.query.field("users") | |
def resolve_users(*_, **kwargs): | |
return self.ds.getUser(**kwargs) |
OlderNewer