Giter VIP home page Giter VIP logo

Comments (7)

deweyjose avatar deweyjose commented on June 15, 2024 2

Query, Mutation and Suscription aren't Netflix DGS requirements, it's a GraphQL requirements.

Not exactly - You can map other types to query, mutation in the schema {} definition block. Perfectly valid as in @jplabadie example. The issue is - client DGS codegen only supports types named Query, Mutation and Subscription in my experience.

from graphqlcodegen.

deweyjose avatar deweyjose commented on June 15, 2024 1

Hi @jplabadie. Glad you find the plugin useful!

This is expected behavior. The maven plugin is a thin wrapper over the Netflix codegen library (same library their gradle plugin uses) which does have a requirement on the root type names - they need to be Query, Mutation and Subscription.

Let us know if there are any other questions.

from graphqlcodegen.

zorglube avatar zorglube commented on June 15, 2024 1

from graphqlcodegen.

deweyjose avatar deweyjose commented on June 15, 2024 1

@jplabadie @zorglube just wanted to follow up here to avoid some confusion.

What you had is a perfectly valid graphql schema. I work with some teams that use something similar using schema to setup query/mutation and mapping query to something like type RootQueryType that defines all of the queries for that particular schema. DGS can generate types for that and run that schema if you're using Java and the rest of the server side libraries they provide.

The problem is generating the client code - the codegen plugin will not generate client code and projections as you noticed unless the type is Query or Mutation. Even if you've specified in the schema {} block what query and mutation types are.

This schema is powered by DGS Java based server - you can see RootQueryType is defined here, not Query, and executed the shows query.

Screen Shot 2022-01-26 at 11 32 09 AM

Here you can see codegen did not generate client code or shows, or any other field on RootQueryType, but did generate code for createShow.

Screen Shot 2022-01-26 at 11 32 22 AM

If we rename RootQueryType to Query in this example DGS codegen will generate code for shows and bars.

If there was any confusion I hope this cleared it up.

from graphqlcodegen.

zorglube avatar zorglube commented on June 15, 2024

You schema seems bad. AS far as I know it might look like this :

 type Something {
  query: QueryRoot
}

type QeryRoot [
 ... 
}

type Query {
  customers(id: String, emailAlias: String, phoneNumber: String): [Customer]
  bookOfTheDead(bookId: String, bookCode: String): BookOfTheDead
}

from graphqlcodegen.

jplabadie avatar jplabadie commented on June 15, 2024

@zorglube @deweyjose

Thank you, and hearing that is the standard really helps. I consider this closed.

from graphqlcodegen.

jplabadie avatar jplabadie commented on June 15, 2024

Yes this is pretty clear. It's simply a convention, not a requirement of GraphQL, but because the schema is pretty sparse syntactically the codegen authors had to make some assumptions about where their plugin could search for Queries, Mutations, and Subscriptions.

Thanks again!

from graphqlcodegen.

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.