Giter Club home page Giter Club logo

graphql-ruby's Introduction

How to GraphQL ๐ŸŽ“

How to GraphQL is a fullstack tutorial website to learn all about GraphQL! It was built by Prisma and many amazing contributors. All content on the site is completely free and open-source.

Note: This repository is currently mostly unmaintained. We are looking for maintainers who can help cleaning up issues and PRs opened by the community. If you are interested in helping out, please reach out!

Content

The content for all tutorials is located in the /content directory. Here is an overview of all the tutorials that are available at the moment:

GraphQL

  • Fundamentals of GraphQL
  • Advanced GraphQL

Frontend

  • React & Apollo
  • React & Relay (Out of date)
  • Vue & Apollo (Out of date)
  • Ember & Apollo (Out of date)

Backend

  • javascript-apollo / JavaScript & Apollo
  • typescript-apollo / Typescript & Apollo
  • typescript-helix / Typescript & Helix
  • graphql-elixir / Absinthe & Elixir
  • graphql-ruby / Ruby and GraphQL Gem
  • graphql-python / Python & Graphene
  • graphql-go / Go & gqlgen
  • graphql-scala / Scala & Sangria
  • graphql-java / Java (Out of date)

Contributions / Fixes

As the whole project is open-source, you're more than welcome to fix typos and other small issues yourself and create a PR for the fix. If you want to contribute a whole tutorial track or update one of the out of date tutorials please get in touch.

Installation & Running locally

The project has some native (gyp) dependencies. To get this running, please make sure your environment it set with the following:

  1. Make sure to install a Node version manager (either fnm or nvm)
  2. Point your environment to the version specified in .nvmrc.
  3. Make sure to load .env to your environment variables (some shell loads it automatically, but if not, you can do: source .env to load it)

You can run a local instance of How to GraphQL by executing the following commands in a terminal:

git clone [email protected]:howtographql/howtographql.git
cd howtographql
yarn install
yarn start # http://localhost:8000/

Note: If you're using Node 8, you might need to invoke npm install -g node-gyp before you're starting the app. More info here.

Troubleshooting

If you are having issues with sharp dependency, please make sure you have installed >0.18.2 of it. Older versions have hardcoded dependency on a legacy artifactory.

To check the version you have, run: yarn why sharp.

If you are still having issues, please make sure that you have SHARP_DIST_BASE_URL environemnt variable set correctly (see .env file) and then run yarn install again.

graphql-ruby's People

Contributors

alanfoster avatar benemdon avatar billfienberg avatar dependabot[bot] avatar eljojo avatar juanitofatas avatar ka8725 avatar nikolasburk avatar rstankov avatar saerdnaer avatar schickling avatar shonorio avatar tb avatar wurde avatar yskttm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

graphql-ruby's Issues

Default pagination

Hi,

Is there a way to set a default pagination ? For example, only the 20 first links ?

Thanks.

Can't technically "Complete" the tutorial

This definitely isn't high priority, but I'm currently unable to technically "complete" the graphql-ruby tutorial. I suspect it's because all of the other tutorials have a multiple choice question at the end of each step, and I suspect those questions are used to track "progress." It seems like the graphql-ruby tutorial doesn't have any of those multiple choice questions at the end of each step.

graphql-ruby-tutorial-no-progress-checkmark

image

iso8601 loses data

I was looking in the library, and it seems like any data sent with ISO8601DateTime is truncated to the nearest second when converted to a DateTime object under the hood. This is actually a bit of a problem because I need my data with milliseconds when sent in this format. Is there a way to do this?

Incorrect defining of type in links_search

type types[Types::LinkType]

type types[Types::LinkType] => type [Types::LinkType]

Causes error when trying to query an allLinks filtered search

"error": {
    "message": "Failed to build return type for Query.allLinks from #<GraphQL::Schema::List:0x00007fcce5b4d7f0 @of_type=Types::LinkType>: Unexpected type input: #<GraphQL::Schema::List:0x00007fcce5b4d7f0> (GraphQL::Schema::List)"

Correct defining of type can be seen in SearchObjectGraphQL README.md

Count on resolver

Its not a Issue, its more like a question of how to graphql

Could you show me how to return the count of a given query with the query data?
Would be useful for pagination if the query return something like:

{
links: [20 links....]
total: 350
}

I'm not understanding how the resolver knows what type of data it returns and how to modifies it.

Connecting with howtographql/react-apollo

I have configured howtographql/react-apollo with:

const networkInterface = createNetworkInterface({
  uri: 'http://localhost:3000/graphql'
})

I have removed the subscriptions, issue #3

Anyway, to get the app to work I still had to do 2 things:

  • add rack-cors - PR #5 (alternative is to set proxy on create-react-app package.json)
  • comment out protect_from_forgery (no idea how to fix it properly atm)

Graphql controller has incorrect variable name

Maybe I'm missing something, but your Graphql controller has a bug in it. I made the mistake of copying it directly and wondered why variables weren't working.

graphql-ruby/app/controllers/graphql_controller.rb

def variables ensure_hash params[:validates] end

Shouldn't the param be ":variables"?

"Cannot return null for non-nullable field CreateUserPayload.user"

I am getting this none descriptive error often when trying to create a user, I am able to figure out what the actual error is.

Error that graphql gives me:

{
  "data": {
    "createUser": null
  },
  "errors": [
    {
      "message": "Cannot return null for non-nullable field CreateUserPayload.user"
    }
  ]
}

The actual error that I get in my resolver is usually related to devise password requirements.

 user.errors.full_messages
=> ["Password is too short (minimum is 6 characters)"]

Here is my mutation:

class Mutations::CreateUser < Mutations::BaseMutation
  argument :name, String, required: true
  argument :email, String, required: true
  argument :password, String, required: true

  field :user, Types::UserType, null: false
  field :email, String, null: false
  field :password, String, null: false
  field :errors, [String], null: false


  def resolve(name:, email:, password:)
    binding.pry
    user = User.create({name: name, email: email, password: password})
    user.persisted? ? { user: user, errors: [] } : { user: nil, errors: user.errors.full_messages }
  end
end

I'd like to make this gem better and more useful. Anyone have any idea the best place look to get started on this fix ?

TypeError: Cannot read property 'types' of undefined on tutorial https://www.howtographql.com/graphql-ruby/7-filtering/

I've following steps in tutorial page https://www.howtographql.com/graphql-ruby/7-filtering/ and after changing field :all_links, resolver: Resolvers::LinksSearch in query_type.rb got an error

TypeError: Cannot read property 'types' of undefined
    at buildClientSchema (http://localhost:3000/assets/graphiql/rails/application.debug-3aff84d172cfc9d5cfec9289f9417ad7ee0ecdb1e7414d33c11cac078d02875e.js:34100:72)
    at http://localhost:3000/assets/graphiql/rails/application.debug-3aff84d172cfc9d5cfec9289f9417ad7ee0ecdb1e7414d33c11cac078d02875e.js:2793:55

I've spent some time and found that issue is in link_search.rb file.

After changing line type types[Types::LinkType] to type [Types::LinkType] (according to readme in https://github.com/rstankov/SearchObjectGraphQL) everything started working fine.

TypeError: Cannot read property 'types' of undefined when completeing tutorial on https://www.howtographql.com/graphql-ruby/2-queries/

I followed all the steps until the end of the https://www.howtographql.com/graphql-ruby/2-queries/ and instead of seeing the documentation in the graphiql UI it will throw an error in the right panel of the graphiql:

TypeError: Cannot read property 'types' of undefined
    at buildClientSchema (http://localhost:3000/assets/graphiql/rails/graphiql-0.12.0.self-84a2376c545f0620e86ec9d8681863a2f1b56b5eb3fe74c45003ff1fb982c1a3.js?body=1:33481:72)
    at http://localhost:3000/assets/graphiql/rails/graphiql-0.12.0.self-84a2376c545f0620e86ec9d8681863a2f1b56b5eb3fe74c45003ff1fb982c1a3.js?body=1:2174:55

Any idea if I did something wrong or is there something in the tutorial that needs to be updated?

DateTimeType undefined

Related to rmosolgo/graphiql-rails#29

In https://www.howtographql.com/graphql-ruby/2-queries/ DateTimeType is used in app/graphql/types/link_type.rb but it's not defined yet.

The result is that when you open http://localhost:3000/graphiql you get

SyntaxError: Unexpected token < in JSON at position 0

graphql_error

I got around the issue by copying date_time_type.rb with a minor adjustment to inherit from GraphQL::Schema::Scalar instead of BaseScalar

Maybe the step to add date_time_type could be added to the tutorial?
Or a default type available in graphql 1.8.13 could be used instead?

Thanks for the great tutorial!

Best practices for testing.

I am finding documentation around testing a bit scarce.

What are some of the best practices for TDD and graphql?

Issue with GraphQL::Types::ISO8601DateTime

Hi,

ruby (2.5.1)
graphql (1.10.5, 1.10.3)

I'm currently having a problem with GraphQL::Types::ISO8601DateTime argument. For some reason I'm getting the error below when passing "2020-04-16" or other ISO8601 formatted strings.

Proxy Handler could not detect JSON: ***/gems/ruby-2.5.1/gems/graphql-1.10.5/lib/graphql/types/iso_8601_date_time.rb:35:in `coerce_result': undefined method `iso8601' for "2020-04-16T00:00:00.000Z":String (NoMethodError)

Any idea what's wrong?

Confusing param :email

Problem

In the ruby tutorial, the mutation for creating a user looks like

class Resolvers::CreateUser < GraphQL::Function
  AuthProviderInput = GraphQL::InputObjectType.define do
    name 'AuthProviderSignupData'

    argument :email, Types::AuthProviderEmailInput
  end

  argument :name, !types.String
  argument :authProvider, !AuthProviderInput

  type Types::UserType

  def call(_obj, args, _ctx)
    User.create!(
      name: args[:name],
      email: args[:authProvider][:email][:email],
      password: args[:authProvider][:email][:password]
    )
  end
end

And creating a user looks like

mutation {
  createUser(
    name: "some_name",
    authProvider: {
      email: {
        email: "[email protected]",
      	password: "1234"
      }
    }
  ) {
    id
    email
    name
  }
}

Since we are using the param email twice, it is easy to mistype the json if you aren't C/P-ing.

Proposed solution

New to this but maybe something like auth_input ?

I can PR this @RStankov

react-apollo AllLinksSearchQuery does not work

When connected via react-apollo (see #4) I can login and see links but search is broken, I see error: ApolloError.js:32 Uncaught (in promise) Error: GraphQL error: Variable searchText of type String! was provided invalid value

I was able to reproduce it in graphiql with:

query AllLinksSearchQuery($searchText: String!) {
  allLinks(filter: {
    OR: [
    	{url_contains: $searchText},
    	{description_contains: $searchText}
    ]
  }) {
    id
    url
    description
  }
}

and query variables:

{
  "$searchText": "Link"
}

I get error:

{
  "errors": [
    {
      "message": "Variable searchText of type String! was provided invalid value",
      "locations": [
        {
          "line": 1,
          "column": 27
        }
      ],
      "value": null,
      "problems": [
        {
          "path": [],
          "explanation": "Expected value to not be null"
        }
      ]
    }
  ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.