GraphQL: Support required fields on output type (#6279)

* Handle required fields

* Fix output fields
This commit is contained in:
Antoine Cormouls
2019-12-15 05:12:04 +01:00
committed by Antonio Davi Macedo Coelho de Castro
parent 2fc328ed24
commit a72ab50c70
3 changed files with 98 additions and 194 deletions

View File

@@ -1886,6 +1886,32 @@ describe('ParseGraphQLServer', () => {
expect(
__type.inputFields.find(o => o.name === 'doors').type.kind
).toEqual('NON_NULL');
const {
data: { __type: __type2 },
} = await apolloClient.query({
query: gql`
query requiredFields {
__type(name: "SuperCar") {
fields {
name
type {
kind
}
}
}
}
`,
});
expect(
__type2.fields.find(o => o.name === 'price').type.kind
).toEqual('SCALAR');
expect(
__type2.fields.find(o => o.name === 'engine').type.kind
).toEqual('NON_NULL');
expect(
__type2.fields.find(o => o.name === 'doors').type.kind
).toEqual('NON_NULL');
});
it('should only allow the supplied output fields for a class', async () => {