Skip to content

Commit

Permalink
Update default extension schema
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Mar 23, 2017
1 parent 5918e4a commit ce09bad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
19 changes: 9 additions & 10 deletions src/default-extend.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
# - @fake
# - @examples
#
# For example:
# extend type Person {
# pet: Pet
# }
#
# type Pet {
# name: String @fake(type:firstName)
# image: String @fake(type:imageUrl, options: {imageCategory:cats})
# }
#
# Press save or Cmd+Enter to apply the changes and update server. Switch to GraphiQL
# on the right panel to immidiatelly test your changes.
#
# Developed with ❤️ by APIs.guru | https://github.com/APIs-guru/graphql-faker

extend type <RootTypeName> {
pet: Pet
}

type Pet {
name: String @fake(type:firstName)
image: String @fake(type:imageUrl, options: {imageCategory:cats})
}
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,14 @@ function buildServerSchema(idl) {
).body);
}

function runServer(schemaIDL, extensionIDL, optionsCB) {
function runServer(schemaIDL: Source, extensionIDL: Source, optionsCB) {
const app = express();

if (extensionIDL) {
const schema = buildServerSchema(schemaIDL);
extensionIDL.body = extensionIDL.body.replace('<RootTypeName>', schema.getQueryType().name);
}

app.use('/graphql', graphqlHTTP(() => {
const schema = buildServerSchema(schemaIDL);

Expand Down

0 comments on commit ce09bad

Please sign in to comment.