Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More examples #52

Open
5 of 11 tasks
MichalLytek opened this issue Mar 29, 2018 · 16 comments
Open
5 of 11 tasks

More examples #52

MichalLytek opened this issue Mar 29, 2018 · 16 comments
Assignees
Labels
Documentation 📖 Issues about docs
Milestone

Comments

@MichalLytek
Copy link
Owner

MichalLytek commented Mar 29, 2018

  • integration with apollo-engine (apollo-cache-control)
  • usage with mongoose (typegoose)
  • usage on client side (Apollo client state)
  • using class mixins
  • GraphQL Modules
  • Join Monster
  • graphql-shield integration
  • using relations betweens types (user -> recipes -> comments)
  • testing examples (unit and e2e)
  • AWS lambda (apollo-server-lambda)
  • sample fullstack project with React and Apollo
@MichalLytek MichalLytek added the Documentation 📖 Issues about docs label Mar 29, 2018
@MichalLytek MichalLytek added this to the 1.0.0 release milestone Mar 29, 2018
@MichalLytek MichalLytek self-assigned this Mar 29, 2018
@sandangel
Copy link

Please add some examples with apollo-server package. especially apollo-server-express and apollo-server-lambda

@MichalLytek
Copy link
Owner Author

Usage of apollo-server-express is the same as in its repository readme:

import express from 'express';
import bodyParser from 'body-parser';
import { graphqlExpress, graphiqlExpress } from 'apollo-server-express';
import { buildSchema } from "type-graphql";

async function bootstrap() {
  // the only different part
  const myGraphQLSchema = await buildSchema({
    resolvers: [__dirname + "/**/*.resolver.ts"],
  });
  const PORT = 3000;

  const app = express();

  // bodyParser is needed just for POST.
  app.use('/graphql', bodyParser.json(), graphqlExpress({ schema: myGraphQLSchema }));
  app.get('/graphiql', graphiqlExpress({ endpointURL: '/graphql' })); // if you want GraphiQL enabled

  app.listen(PORT);
}

bootstrap();

apollo-server-lambda usage looks the same as the only demand is to provide schema myGraphQLSchema = require('./schema'); so you might need to use buildSchemaSync function. However it's more complicated so I will try create an AWS free tier and try the lambda 😉

@sandangel
Copy link

sandangel commented May 23, 2018

@19majkel94 thank you it works. This is just brilliant. I actually have found a way to integrate with injection-js as well. Hope this will be released soon. Actually you don't need to create an aws account. You can try it with serverless framework and serverless-offline plugin to emulate lambda environment at your local machine.

@darbio

This comment has been minimized.

@sandangel

This comment has been minimized.

@MichalLytek

This comment has been minimized.

@darbio

This comment has been minimized.

@codingmaven
Copy link

Is there any code samples for e2e tests?

@MichalLytek
Copy link
Owner Author

@codingmaven A lot of in tests folder 😄

const query = `{
  myQuery {
    myField
  }
}`;

const { data } = await graphql(schema, query);

expect(data!.myQuery.myField).toEqual("myFieldValue");

@RodolfoSilva
Copy link

@19majkel94 do you have any testing examples with typeorm?

@MichalLytek
Copy link
Owner Author

@RodolfoSilva Just use the dependency injection (TypeDI) and data mapper patter (repository) as in the typeorm-typegraphql examples here on repo. Then you can easily mock the object passed to the constructor in unit test to stub the DB access.

@ramonpm
Copy link

ramonpm commented Jun 29, 2019

Hi there, would like to add +1 request to AWS Lambda example because it has been very annoying to set up this to work there.
I have this repository (https://github.com/ramonpm/typescript-serverless-graphql) running and working fine with serverless offline. However, once I deploy it to AWS lambda, I get this error

Unable to import module 'handler': Error
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.source-map-support (/var/task/handler.js:29922:18)
    at __webpack_require__ (/var/task/handler.js:20:30)
    at Object../source-map-install.js (/var/task/handler.js:29722:1)
    at __webpack_require__ (/var/task/handler.js:20:30)
    at Object.0 (/var/task/handler.js:29733:1)
    at __webpack_require__ (/var/task/handler.js:20:30)

Which is probably due to externals: [nodeExternals()], in my webpack.config.js but if I don't use that it fails badly with Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm
Thought about creating a new issue, but I noticed they have being closed pointing to this issue...

@visheshd
Copy link

visheshd commented Jul 2, 2019

@ramonpm here is a working version that I setup
https://github.com/causecode/type-graphql-typegoose-serverless

And another set of examples at https://github.com/kirill578/type-graphql-serverless-example

@ramonpm
Copy link

ramonpm commented Jul 5, 2019

Thank you @visheshd
It turned out that for some reason I don't really care I had to use --useSeparateProcesses to run it locally without the conflicts. Should I care 😅 though ?

@omar-dulaimi
Copy link

Apollo server lambda is an example I would really appreciate seeing today.

@itpropro
Copy link

Can we add Azure Functions to that list @MichalLytek? I would be able to provide a working example the following days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation 📖 Issues about docs
Projects
None yet
Development

No branches or pull requests

9 participants