Code Monkey home page Code Monkey logo

Comments (4)

jlouis avatar jlouis commented on August 23, 2024

Yes, I agree we should be doing something about this. It should be fairly easy to produce a better error message by detecting this explicitly.

from graphql-erlang.

jlouis avatar jlouis commented on August 23, 2024

Rough debugging plan:

  • Figure out which part of the code the problem occurs in: parser? The canonicalizer itself?
  • Handle this gracefully, either by ignoring the annotation, or by failing whenever there are an excess of unknown annotations.

The latter is up for discussion: both semantics are pretty nice: ignoring means you can extend it with stuff in advance. But then again, it also means you don't get an error report, and then you might be confused later on, when the expected behavior isn't there (why is my descriptions not showing up in my API introspection?)

from graphql-erlang.

jlouis avatar jlouis commented on August 23, 2024

Better fix for this one: In #161 descriptions are optional (block-) strings on types. So we have somethng like

"Geolocated coordinates"
type Geo {
    "The latitude of the geolocation"
    latitude: Float!
    "The longitude of the geolocation"
    longitude: Float!
}

Which completely solves this problem going forward. Also annotations such as +description will go away since we can just add them as directives to the server. Instead of e.g., +private you can write:

"The Foo object"
type Foo {
    "The private geo position of the Foo object"
    geo: Geo! @private
}

This naturally reuses the directive notion and internally it also makes a lot of sense since annotations and directives share a lot of the same code path, but they are really the same kind of thing.

from graphql-erlang.

jlouis avatar jlouis commented on August 23, 2024

The initial (concrete) fix for this has been merged and documentation are now docstrings as per the Jun2018 specification.

As for directives, we plan to support them as per the Jun2018 spec as well. You would write something like the following to implement the old behavior:

directive @ description (text: String) on
  | SCHEMA
  | SCALAR
  | OBJECT
  | FIELD_DEFINITION
  | ARGUMENT_DEFINITION
  | INTERFACE
  | UNION
  | ENUM
  | ENUM_VALUE
  | INPUT_OBJECT
  | INPUT_FIELD_DEFINITION

Which is then entered into the type checker. This will have the type checker detect an error if you use capitalized Text in lieu of text. GraphQL is case sensitive in general, so this follows the basic rules of the game.

NOTE: The example is somewhat degenerate insofar it implements a feature which has been added to the specification. But it shows how a programmer is able to extend the schema with their own ruleset.

from graphql-erlang.

Related Issues (20)

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.