aerogear / graphback

Graphback - Out of the box GraphQL server and client
https://graphback.dev
Apache License 2.0
409 stars 73 forks source link

Schema printer should skip printing for default scalars #775

Closed wtrocki closed 4 years ago

wtrocki commented 4 years ago

We need to filter out Integer, String scalars from result schema. Implementation we use now is here https://github.com/aerogear/graphback/blob/master/packages/graphback-codegen-schema/src/writer/schemaPrinter.ts

jaskeerat789 commented 4 years ago

can you pls elaborate the issue

wtrocki commented 4 years ago

Generated schema contains some extra scalars. They should not be there. example https://github.com/aerogear/ionic-showcase/blob/master/server/src/schema/schema.graphql#L23

wtrocki commented 4 years ago

To replicate issue we need to add offix plugin that is using some helpers for schema

jaskeerat789 commented 4 years ago
 const orderedTypes = schemaTypes.filter((schemaType: GraphQLObjectType) => {
        if (isQueryType(schema, schemaType)) {
            return false;
        }
        if (isSubscriptionType(schema, schemaType)) {
            return false;
        }
        if (isMutationType(schema, schemaType)) {
            return false;
        }

        return schemaType.astNode !== undefined;
    }).sort((type1: GraphQLObjectType, type2: GraphQLObjectType) => {
        return type1.astNode?.loc?.start - type2.astNode?.loc?.start
    })

https://github.com/aerogear/graphback/blob/master/packages/graphback-codegen-schema/src/writer/schemaPrinter.ts#L57

I think i we need to add another filter here for the default scalar types (Int and String)

craicoverflow commented 4 years ago

Fixed in https://github.com/aerogear/graphback/pull/736/commits/76c9fa2e102e5ef1bb66823567c52abf4bb371a3