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

Possible Excursion: Mocking and Changing Data Endpoints #42

Open
hammannja opened this issue Jan 9, 2017 · 3 comments
Open

Possible Excursion: Mocking and Changing Data Endpoints #42

hammannja opened this issue Jan 9, 2017 · 3 comments

Comments

@hammannja
Copy link

Loved the React Tutorial!

In the tutorial, you do the wonderful thing of setting up a client data interface for us to an existing back-end: networkInterface: createNetworkInterface({ uri: 'https://api.graph.cool/simple/v1/cix0ooaws024k0132n9tbc5p9'}),

It would be nice to have an Excursion or Track specifically on the data layer. Specifically, it would be great to see an excursion demonstrating no data back-end (using graphql-tools mocking features), and then a conversion of that no data back-end environment to the creation of a back-end. With enough topics (e.g., pulling from two data sources within one qraphql query), this might even be more than an Excursion, and instead a separate Track!

Thanks!

@tychota
Copy link
Contributor

tychota commented Jan 10, 2017

Hey,

thank for the kind words.

It is true that we don't cover the server part. In LearnApollo, we focused on the client part, because there are literally 100 ways to make a graphQL server. We though the scope was too large, and admittedly, it is pretty easy for newcomers to start with GraphCool (I don't work at GraphCool) : they don't have to buy a server, understand how to do authentication, understand how to optimise the server for the n query problem, etc.. While those topics are interesting, it is also easier to start with a SAAS and visualise the benefit in term of decoupling and optimised, readable code.

I think that it will be nice to have a full new website learngraphqlserver.com or whatever, and put those topics over there.

@hammannja
Copy link
Author

hammannja commented Jan 28, 2017

Thanks for the response.

In keeping with the focus of Learn Apollo on the client side, I attempted to add the data mocking capabilities provided by graphql-tools into one of the examples.

  1. I did: "npm install --save graphql-tools graphql" (graphql is a dependency of graphql-tools).
  2. I also npm updated all of the dependencies and validated that the Application still worked post-update (it did!).
  3. I then went to http://dev.apollodata.com/tools/graphql-tools/mocking.html#Default-mock-example and copied the import statements and code into Pokedex.js
    a. I commented out "import { graphql } from 'graphql';" because the page was already importing graphql from "react-apollo."
  4. I inserted the schema provided at https://www.learnapollo.com/tutorial-react/react-02/#introduction in between the "const schemaString = ...;" single-parentheses.
  5. I opened a terminal window and entered "npm start" (after already doing "npm init" in the folder).

I get the following error: "Uncaught Error: Must provide schema definition with query type or a type named Query."

I suspect the solution to this problem is easy to solve, but the existing documentation doesn't help me get there. I would appreciate help solving it and I think this would be helpful to many others.

Conclusion: The front-end examples provided at LearnApollo are currently the best examples I have found for actually learning Apollo at the level of detail necessary to use the examples as a beginning template to start building a person's new App on their own. It includes many details that are not documented or are poorly documented. In order for a person to build their own new App without setting up their own Graphql server (using Apollo Group's Graphql First development mindset), the person needs to add mock capabilities and, later, completely decouple the application from the Pokedex server you wonderfully provided. They can then work on their App for weeks/months before having to figure out how to set up their back-end. It would be helpful if you provided those transition steps to new Apollo developers.

Thanks again for all of your hard work.

@Kanairy
Copy link
Contributor

Kanairy commented Feb 11, 2017

@hammannja,

You can always use a service like https://www.graph.cool/ to make your own graphql endpoint to play with. In fact, the Pokedex server used in the lessons are hosted by graphcool. I agree with @tychota, a full new url with the purpose of teaching gql server would me most suitable.

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

No branches or pull requests

3 participants