Giter Club home page Giter Club logo

Comments (6)

kirill-konshin avatar kirill-konshin commented on March 29, 2024 8

I found a weird behavior, probably it deserves another bug, but I think I should start here.

When schema definition is wrapped in gql template all the descriptions are lost. It does not matter if the string is inlined or loaded from a file.

I am using [email protected], here's the part of schema:

type PlaylistShort implements PlaylistInterface {
    # integer ID: 123 (RO)
    id: ID!
    # playlist title: "S-Bahn Sounds" (RW)
    title: String
    # (RW)
    tracks: [TrackShort]
}

And here's what is returned by introspection query:

image

All description fields are empty...

Apollo server creation code:

const typeDefs = readFileSync(path.join(__dirname, 'src', 'apollo', 'schema.graphqls')).toString();

export const apolloServer = new ApolloServer({
    typeDefs: gql`${typeDefs}`,
    resolvers,
    introspection: true,
    tracing: true,
    context: ({req}) => ({
        authHeader: req.headers['authheader']
    })
});

If I replace

typeDefs: gql`${typeDefs}`

... with

typeDefs: typeDefs,

... it starts to work as expected.

from apollo-server.

lorensr avatar lorensr commented on March 29, 2024 6

This was added in graphql/graphql-js#464

and now works as a # comment in the schema string:

https://github.com/apollostack/GitHunt-API/blob/master/api/schema.js#L9

from apollo-server.

helfer avatar helfer commented on March 29, 2024 2

The GraphQL schema language doesn't support descriptions at the moment (only deprecation, via decorators), but you can do it via resolvers. Check out this test to see how it works: https://github.com/apollostack/graphql-tools/blob/00d01eba94e8dbd21973e71b3cfd4361fdd8961d/test/testSchemaGenerator.js#L389

If you want to set a description on a type (as opposed to a field), you can do that by adding a __description field on the type (in resolvers, not in the schema). I know it's not ideal, but it's a temporary solution until a description PR (graphql/graphql-js#427) is merged in GraphQL.js

from apollo-server.

vladinator1000 avatar vladinator1000 commented on March 29, 2024

That doesn't seem bad, thanks!

from apollo-server.

vladinator1000 avatar vladinator1000 commented on March 29, 2024

Also, thank you so much for the lightning responses Jonas, you're awesome!

from apollo-server.

wszgxa avatar wszgxa commented on March 29, 2024

same issue with @kirill-konshin ... don't know it's designed by that or it's an issue.

Could we create another issue for this?

from apollo-server.

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.